8009984: [parfait] Buffer overrun at jdk/src/macosx/native/com/apple/laf/AquaFileView.m
authoralexsch
Tue, 11 Jun 2013 16:30:34 +0400
changeset 18127 34b13e7c5af5
parent 18126 ad2f991576db
child 18128 3492cc60d273
8009984: [parfait] Buffer overrun at jdk/src/macosx/native/com/apple/laf/AquaFileView.m Reviewed-by: serb, art
jdk/src/macosx/native/com/apple/laf/AquaFileView.m
--- a/jdk/src/macosx/native/com/apple/laf/AquaFileView.m	Tue Jun 11 16:02:22 2013 +0400
+++ b/jdk/src/macosx/native/com/apple/laf/AquaFileView.m	Tue Jun 11 16:30:34 2013 +0400
@@ -187,13 +187,13 @@
 JNF_COCOA_ENTER(env);
 
     UInt8 pathCString[MAXPATHLEN + 1];
-    size_t pathSize = sizeof(pathCString);
+    size_t maxPathLen = sizeof(pathCString) - 1;
 
     jbyte *byteArray = (*env)->GetByteArrayElements(env, pathToAlias, NULL);
     jsize length = (*env)->GetArrayLength(env, pathToAlias);
 
-    if (length > pathSize) {
-        length = pathSize;
+    if (length > maxPathLen) {
+        length = maxPathLen;
     }
     strncpy((char *)pathCString, (char *)byteArray, length);
     // make sure it's null terminated