hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmcc...@apache.org
Subject svn commit: r1491943 - /hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/net/unix/DomainSocket.c
Date Tue, 11 Jun 2013 20:29:07 GMT
Author: cmccabe
Date: Tue Jun 11 20:29:06 2013
New Revision: 1491943

URL: http://svn.apache.org/r1491943
Log:
HADOOP-9635. Fix potential stack overflow in DomainSocket.c (V. Karthik Kumar via cmccabe)


Modified:
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/net/unix/DomainSocket.c

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/net/unix/DomainSocket.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/net/unix/DomainSocket.c?rev=1491943&r1=1491942&r2=1491943&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/net/unix/DomainSocket.c
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/net/unix/DomainSocket.c
Tue Jun 11 20:29:06 2013
@@ -276,12 +276,13 @@ JNIEnv *env, jclass clazz, jobject jstr,
   jthrowable jthr = NULL;
 
   utfLength = (*env)->GetStringUTFLength(env, jstr);
-  if (utfLength > sizeof(path)) {
+  if (utfLength > (sizeof(path)-1)) {
     jthr = newIOException(env, "path is too long!  We expected a path "
-        "no longer than %zd UTF-8 bytes.", sizeof(path));
+        "no longer than %zd UTF-8 bytes.", (sizeof(path)-1));
     goto done;
   }
   (*env)->GetStringUTFRegion(env, jstr, 0, utfLength, path);
+  path [ utfLength ] = 0;
   jthr = (*env)->ExceptionOccurred(env);
   if (jthr) {
     (*env)->ExceptionClear(env);
@@ -305,7 +306,7 @@ JNIEnv *env, jclass clazz, jobject jstr,
   // be a directory.  (If it is a directory, we will fail to create the socket
   // later with EISDIR or similar.)
   for (check[0] = '/', check[1] = '\0', rest = path, token = "";
-       token && rest[0];
+       token && rest && rest[0];
        token = strtok_r(rest, "/", &rest)) {
     if (strcmp(check, "/") != 0) {
       // If the previous directory we checked was '/', we skip appending another



Mime
View raw message