-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
11.0.15
-
x86_64
-
windows_7
ADDITIONAL SYSTEM INFORMATION :
Windows 7
A DESCRIPTION OF THE PROBLEM :
A customer of our software reported a exception during printing. During our analysis we found it occurs in the Win32PrintService
Stacktrace:
Client exception occurred: e = java.lang.ArrayIndexOutOfBoundsException: Index 192 out of bounds for length 192.
java.lang.ArrayIndexOutOfBoundsException: Index 192 out of bounds for length 192
at java.desktop/sun.print.Win32PrintService.getMediaSizes(Win32PrintService.java:677)
at java.desktop/sun.print.Win32PrintService.initMedia(Win32PrintService.java:388)
at java.desktop/sun.print.Win32PrintService.getSupportedAttributeValues(Win32PrintService.java:1386)
at caprich.client/ch.bedag.gba.capitastra.clientgui.printing.ClientPrintProducts.getPrintTray(ClientPrintProducts.java:188)
After some digging we see that the bug occurs here
https://github.com/openjdk/jdk/blob/fe807217a79753f84c00432e7451c17baa6645c5/src/java.desktop/windows/classes/sun/print/Win32PrintService.java#L631
in those line of codes
int[] mediaSz = getAllMediaSizes(printer, prnPort);
String[] winMediaNames = getAllMediaNames(printer, prnPort);
int nMedia = mediaSz.length/2;
for (int i = 0; i < nMedia; i++, ms=null) {
Win32MediaSize wms = Win32MediaSize.findMediaName(winMediaNames[i]);
nMedia is calculated of the length of mediaSz Array
In the for loop i will go to the size of nMedia-1
now it tries to get the value out of winMediaNames[i] but this Array may be of shorter length. which will throw an ArrayIndexOutOfBoundsException
There should be a check so that nMedia can not be bigger than winMediaNames.length.
There is already a fix for a similar issue here
https://github.com/openjdk/jdk/blob/fe807217a79753f84c00432e7451c17baa6645c5/src/java.desktop/windows/classes/sun/print/Win32PrintService.java#L572
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
we can not reproduce it, because it depends on installed printers and drivers
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no exception
ACTUAL -
An ArrayIndexOutOfBoundsException
CUSTOMER SUBMITTED WORKAROUND :
Try Again or print on a different PC
We ask our Customer to update the printer drivers perhaps this will fix the issue for him.
FREQUENCY : often
Windows 7
A DESCRIPTION OF THE PROBLEM :
A customer of our software reported a exception during printing. During our analysis we found it occurs in the Win32PrintService
Stacktrace:
Client exception occurred: e = java.lang.ArrayIndexOutOfBoundsException: Index 192 out of bounds for length 192.
java.lang.ArrayIndexOutOfBoundsException: Index 192 out of bounds for length 192
at java.desktop/sun.print.Win32PrintService.getMediaSizes(Win32PrintService.java:677)
at java.desktop/sun.print.Win32PrintService.initMedia(Win32PrintService.java:388)
at java.desktop/sun.print.Win32PrintService.getSupportedAttributeValues(Win32PrintService.java:1386)
at caprich.client/ch.bedag.gba.capitastra.clientgui.printing.ClientPrintProducts.getPrintTray(ClientPrintProducts.java:188)
After some digging we see that the bug occurs here
https://github.com/openjdk/jdk/blob/fe807217a79753f84c00432e7451c17baa6645c5/src/java.desktop/windows/classes/sun/print/Win32PrintService.java#L631
in those line of codes
int[] mediaSz = getAllMediaSizes(printer, prnPort);
String[] winMediaNames = getAllMediaNames(printer, prnPort);
int nMedia = mediaSz.length/2;
for (int i = 0; i < nMedia; i++, ms=null) {
Win32MediaSize wms = Win32MediaSize.findMediaName(winMediaNames[i]);
nMedia is calculated of the length of mediaSz Array
In the for loop i will go to the size of nMedia-1
now it tries to get the value out of winMediaNames[i] but this Array may be of shorter length. which will throw an ArrayIndexOutOfBoundsException
There should be a check so that nMedia can not be bigger than winMediaNames.length.
There is already a fix for a similar issue here
https://github.com/openjdk/jdk/blob/fe807217a79753f84c00432e7451c17baa6645c5/src/java.desktop/windows/classes/sun/print/Win32PrintService.java#L572
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
we can not reproduce it, because it depends on installed printers and drivers
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no exception
ACTUAL -
An ArrayIndexOutOfBoundsException
CUSTOMER SUBMITTED WORKAROUND :
Try Again or print on a different PC
We ask our Customer to update the printer drivers perhaps this will fix the issue for him.
FREQUENCY : often