changeset 6975:2cc8437acff9

Merge
author mullan
date Fri, 10 May 2013 16:36:06 -0400
parents c2698b462a49 (current diff) 3abe390615e3 (diff)
children e4305995090b
files
diffstat 3 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java	Fri May 10 16:28:51 2013 -0400
+++ b/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java	Fri May 10 16:36:06 2013 -0400
@@ -1160,6 +1160,11 @@
             target = imRas;
         }
         int [] bandSizes = target.getSampleModel().getSampleSize();
+        for (int i = 0; i < bandSizes.length; i++) {
+            if (bandSizes[i] <= 0 || bandSizes[i] > 8) {
+                throw new IIOException("Illegal band size: should be 0 < size <= 8");
+            }
+        }
 
         /*
          * If the process is sequential, and we have restart markers,
--- a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java	Fri May 10 16:28:51 2013 -0400
+++ b/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java	Fri May 10 16:36:06 2013 -0400
@@ -490,8 +490,8 @@
             // handle <= 8-bit samples.  We now check the band sizes and throw
             // an exception for images, such as USHORT_GRAY, with > 8 bits
             // per sample.
-            if (bandSizes[i] > 8) {
-                throw new IIOException("Sample size must be <= 8");
+            if (bandSizes[i] <= 0 || bandSizes[i] > 8) {
+                throw new IIOException("Illegal band size: should be 0 < size <= 8");
             }
             // 4450894 part 2: We expand IndexColorModel images to full 24-
             // or 32-bit in grabPixels() for each scanline.  For indexed
--- a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Fri May 10 16:28:51 2013 -0400
+++ b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Fri May 10 16:36:06 2013 -0400
@@ -2675,6 +2675,15 @@
     bandSize = (*env)->GetIntArrayElements(env, bandSizes, NULL);
 
     for (i = 0; i < numBands; i++) {
+        if (bandSize[i] <= 0 || bandSize[i] > JPEG_BAND_SIZE) {
+            (*env)->ReleaseIntArrayElements(env, bandSizes,
+                                            bandSize, JNI_ABORT);
+            JNU_ThrowByName(env, "javax/imageio/IIOException", "Invalid Image");
+            return JNI_FALSE;;
+        }
+    }
+
+    for (i = 0; i < numBands; i++) {
         if (bandSize[i] != JPEG_BAND_SIZE) {
             if (scale == NULL) {
                 scale = (UINT8**) calloc(numBands, sizeof(UINT8*));