changeset 7012:33d856938d83

8029854: Enhance JPEG decodings Reviewed-by: bae, vadim, mschoene
author prr
date Thu, 19 Dec 2013 09:20:59 -0800
parents 9e7bfab5bb87
children 56161b644cbc
files src/share/native/sun/awt/image/gif/gifdecoder.c src/share/native/sun/awt/image/jpeg/imageioJPEG.c src/share/native/sun/awt/image/jpeg/jpegdecoder.c
diffstat 3 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/native/sun/awt/image/gif/gifdecoder.c	Tue Dec 17 13:59:04 2013 +0400
+++ b/src/share/native/sun/awt/image/gif/gifdecoder.c	Thu Dec 19 09:20:59 2013 -0800
@@ -249,6 +249,7 @@
                 /* fill the block */
                 len = (*env)->CallIntMethod(env, this, readID,
                                             blockh, remain, blockLength + 1);
+                if (len > blockLength + 1) len = blockLength + 1;
                 if ((*env)->ExceptionOccurred(env)) {
                     return 0;
                 }
--- a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Tue Dec 17 13:59:04 2013 +0400
+++ b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Thu Dec 19 09:20:59 2013 -0800
@@ -939,6 +939,7 @@
                                 JPEGImageReader_readInputDataID,
                                 sb->hstreamBuffer, 0,
                                 sb->bufferLength);
+    if (ret > sb->bufferLength) ret = sb->bufferLength;
     if ((*env)->ExceptionOccurred(env)
         || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
             cinfo->err->error_exit((j_common_ptr) cinfo);
@@ -1035,6 +1036,7 @@
                                 JPEGImageReader_readInputDataID,
                                 sb->hstreamBuffer,
                                 offset, buflen);
+    if (ret > buflen) ret = buflen;
     if ((*env)->ExceptionOccurred(env)
         || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
         cinfo->err->error_exit((j_common_ptr) cinfo);
--- a/src/share/native/sun/awt/image/jpeg/jpegdecoder.c	Tue Dec 17 13:59:04 2013 +0400
+++ b/src/share/native/sun/awt/image/jpeg/jpegdecoder.c	Thu Dec 19 09:20:59 2013 -0800
@@ -289,6 +289,7 @@
     buflen = (*env)->GetArrayLength(env, src->hInputBuffer);
     ret = (*env)->CallIntMethod(env, src->hInputStream, InputStream_readID,
                                 src->hInputBuffer, 0, buflen);
+    if (ret > buflen) ret = buflen;
     if ((*env)->ExceptionOccurred(env) || !GET_ARRAYS(env, src)) {
         cinfo->err->error_exit((struct jpeg_common_struct *) cinfo);
     }
@@ -349,6 +350,7 @@
     }
     ret = (*env)->CallIntMethod(env, src->hInputStream, InputStream_readID,
                                 src->hInputBuffer, offset, buflen);
+    if (ret > buflen) ret = buflen;
     if ((*env)->ExceptionOccurred(env) || !GET_ARRAYS(env, src)) {
         cinfo->err->error_exit((struct jpeg_common_struct *) cinfo);
     }
@@ -424,6 +426,7 @@
         ret = (*env)->CallIntMethod(env, src->hInputStream,
                                     InputStream_readID,
                                     src->hInputBuffer, 0, buflen);
+        if (ret > buflen) ret = buflen;
         if ((*env)->ExceptionOccurred(env)) {
             cinfo->err->error_exit((struct jpeg_common_struct *) cinfo);
         }