8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
authorpchelko
Wed, 19 Jun 2013 17:12:23 +0400
changeset 18135 d9be76f1a19c
parent 18134 af8df2260431
child 18136 af4117c9b587
child 18520 7fad3f87d731
8005661: [parfait] Possible buffer overrun in jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c 8005695: [parfait] Format string argument mismatch in jdk/src/solaris/native/sun/xawt/XToolkit.c 8005752: [parfait] False positive function call mismatch at jdk/src/solaris/native/sun/xawt/XWindow.c Reviewed-by: art, serb
jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
jdk/src/solaris/native/sun/awt/awt_InputMethod.c
jdk/src/solaris/native/sun/xawt/XToolkit.c
--- a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Wed Jun 19 14:28:44 2013 +0400
+++ b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Wed Jun 19 17:12:23 2013 +0400
@@ -1366,12 +1366,18 @@
     mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V");
     if (mid != NULL) {
         if (usingXinerama) {
-            bounds = (*env)->NewObject(env, clazz, mid, fbrects[screen].x,
-                                                        fbrects[screen].y,
-                                                        fbrects[screen].width,
-                                                        fbrects[screen].height);
-        }
-        else {
+            if (0 <= screen && screen < awt_numScreens) {
+                bounds = (*env)->NewObject(env, clazz, mid, fbrects[screen].x,
+                                                            fbrects[screen].y,
+                                                            fbrects[screen].width,
+                                                            fbrects[screen].height);
+            } else {
+                jclass exceptionClass = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+                if (exceptionClass != NULL) {
+                    (*env)->ThrowNew(env, exceptionClass, "Illegal screen index");
+                }
+            }
+        } else {
             XWindowAttributes xwa;
             memset(&xwa, 0, sizeof(xwa));
 
--- a/jdk/src/solaris/native/sun/awt/awt_InputMethod.c	Wed Jun 19 14:28:44 2013 +0400
+++ b/jdk/src/solaris/native/sun/awt/awt_InputMethod.c	Wed Jun 19 17:12:23 2013 +0400
@@ -447,7 +447,7 @@
  */
 #define INITIAL_LOOKUP_BUF_SIZE 512
 
-Bool
+Boolean
 awt_x11inputmethod_lookupString(XKeyPressedEvent *event, KeySym *keysymp)
 {
     JNIEnv *env = GetJNIEnv();
@@ -457,8 +457,8 @@
     int mblen;
     jstring javastr;
     XIC ic;
-    Bool result = True;
-    static Bool composing = False;
+    Boolean result = True;
+    static Boolean composing = False;
 
     /*
       printf("lookupString: entering...\n");
--- a/jdk/src/solaris/native/sun/xawt/XToolkit.c	Wed Jun 19 14:28:44 2013 +0400
+++ b/jdk/src/solaris/native/sun/xawt/XToolkit.c	Wed Jun 19 17:12:23 2013 +0400
@@ -685,8 +685,7 @@
     if (result == 0) {
         /* poll() timed out -- update timeout value */
         update_poll_timeout(TIMEOUT_TIMEDOUT);
-        PRINT2("%s(): TIMEOUT_TIMEDOUT curPollTimeout = %d \n",
-              performPoll, curPollTimeout);
+        PRINT2("performPoll(): TIMEOUT_TIMEDOUT curPollTimeout = %d \n", curPollTimeout);
     }
     if (pollFds[1].revents) {
         int count;
@@ -695,14 +694,12 @@
         do {
             count = read(AWT_READPIPE, read_buf, AWT_POLL_BUFSIZE );
         } while (count == AWT_POLL_BUFSIZE );
-        PRINT2("%s():  data on the AWT pipe: curPollTimeout = %d \n",
-               performPoll, curPollTimeout);
+        PRINT2("performPoll():  data on the AWT pipe: curPollTimeout = %d \n", curPollTimeout);
     }
     if (pollFds[0].revents) {
         // Events in X pipe
         update_poll_timeout(TIMEOUT_EVENTS);
-        PRINT2("%s(): TIMEOUT_EVENTS curPollTimeout = %ld \n",
-               performPoll, curPollTimeout);
+        PRINT2("performPoll(): TIMEOUT_EVENTS curPollTimeout = %ld \n", curPollTimeout);
     }
     return;