]> xenbits.xen.org Git - xenclient/uclibc.git/commitdiff
fix realpath NULL buffer self-allocation master public/master
authorVincent Hanquez <vincent.hanquez@eu.citrix.com>
Tue, 10 Feb 2009 12:08:34 +0000 (12:08 +0000)
committerVincent Hanquez <vincent.hanquez@eu.citrix.com>
Tue, 10 Feb 2009 12:08:34 +0000 (12:08 +0000)
include/stdlib.h
libc/stdlib/realpath.c

index b87dfd921421fe8d6d2f19aafd9813f0697259b3..9b112d8943768e97b94546a11baf7a02b5ae2306 100644 (file)
@@ -637,7 +637,7 @@ extern char *canonicalize_file_name (__const char *__name)
    name in RESOLVED.  */
 /* we choose to handle __resolved==NULL as crash :) */
 extern char *realpath (__const char *__restrict __name,
-                      char *__restrict __resolved) __THROW __wur __nonnull((2));
+                      char *__restrict __resolved) __THROW __wur;
 #endif
 
 
index e9eabdfaa8bbee71ca2aace3b1ad2ce23cbae141..fe8fdd602666317c09904c373715c2b6dbd6e592 100644 (file)
@@ -74,6 +74,15 @@ char got_path[];
                __set_errno(ENAMETOOLONG);
                return NULL;
        }
+
+       if (!got_path) {
+               got_path = malloc(PATH_MAX);
+               if (!got_path) {
+                       __set_errno(ENOMEM);
+                       return NULL;
+               }
+       }
+
        /* Copy so that path is at the end of copy_path[] */
        strcpy(copy_path + (PATH_MAX-1) - path_len, path);
        path = copy_path + (PATH_MAX-1) - path_len;