# HG changeset patch # User bae # Date 1297934509 -10800 # Node ID df445f522425f4665433d5d22e9b3776973b2d35 # Parent aca0dc2b921c785418463949618b0b7176bda6d8 7013519: [parfait] Integer overflows in 2D code Reviewed-by: prr, valeriep diff -r aca0dc2b921c -r df445f522425 src/share/native/sun/awt/image/jpeg/imageioJPEG.c --- a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Wed Feb 09 11:50:29 2011 +0800 +++ b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Thu Feb 17 12:21:49 2011 +0300 @@ -1971,6 +1971,13 @@ return data->abortFlag; } + if (cinfo->output_components <= 0 || + cinfo->image_width > (0xffffffffu / (unsigned int)cinfo->output_components)) + { + JNU_ThrowByName(env, "javax/imageio/IIOException", + "Invalid number of output components"); + return data->abortFlag; + } // Allocate a 1-scanline buffer scanLinePtr = (JSAMPROW)malloc(cinfo->image_width*cinfo->output_components); diff -r aca0dc2b921c -r df445f522425 src/share/native/sun/font/layout/SunLayoutEngine.cpp --- a/src/share/native/sun/font/layout/SunLayoutEngine.cpp Wed Feb 09 11:50:29 2011 +0800 +++ b/src/share/native/sun/font/layout/SunLayoutEngine.cpp Thu Feb 17 12:21:49 2011 +0300 @@ -186,7 +186,11 @@ jchar buffer[256]; jchar* chars = buffer; if (len > 256) { - chars = (jchar*)malloc(len * sizeof(jchar)); + size_t size = len * sizeof(jchar); + if (size / sizeof(jchar) != len) { + return; + } + chars = (jchar*)malloc(size); if (chars == 0) { return; }