Explorar o código

handle file_name==NULL and file_name=="" as required by POSIX

Mike Frysinger %!s(int64=18) %!d(string=hai) anos
pai
achega
66b987ac3b
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      libc/stdlib/realpath.c

+ 8 - 0
libc/stdlib/realpath.c

@@ -58,6 +58,14 @@ char resolved_path[];
 	int readlinks = 0;
 	int n;
 
+	if (path == NULL) {
+		__set_errno(EINVAL);
+		return NULL;
+	}
+	if (*path == '\0') {
+		__set_errno(ENOENT);
+		return NULL;
+	}
 	/* Make a copy of the source path since we may need to modify it. */
 	if (strlen(path) >= PATH_MAX - 2) {
 		__set_errno(ENAMETOOLONG);