realpath(1): Return ENOENT if filename is empty string.
authorStathis Kamperis <beket@dragonflybsd.org>
Fri, 1 Jan 2010 13:55:34 +0000 (15:55 +0200)
committerStathis Kamperis <beket@dragonflybsd.org>
Fri, 1 Jan 2010 13:55:39 +0000 (15:55 +0200)
Mandated by POSIX.

Linux, NetBSD and OpenSolaris do the same, so we are on
the safe side.

Shortly-discussed-with: aggelos@

lib/libc/stdlib/realpath.c

index 8e27fd0..7d7afba 100644 (file)
@@ -63,7 +63,11 @@ realpath(const char *path, char resolved[PATH_MAX])
                errno = EINVAL;
                return (NULL);
        }
-       if (path[0] == '/') {
+       if (path[0] == '\0') {
+               errno = ENOENT;
+               return (NULL);
+       }
+       else if (path[0] == '/') {
                resolved[0] = '/';
                resolved[1] = '\0';
                if (path[1] == '\0')