Browse Source

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

Mike Frysinger 17 years ago
parent
commit
66b987ac3b
1 changed files with 8 additions and 0 deletions
  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);