[PATCH, HURD]: null pathnames shall return ENOENT
Samuel Thibault
samuel.thibault@ens-lyon.org
Sun Sep 13 15:40:00 GMT 2009
Hello,
Here is a patch to fix chdir("") and chroot("") into returning ENOENT as
required by POSIX.
Samuel
2009-09-13 Samuel Thibault <samuel.thibault@ens-lyon.org>
* hurd/hurdchdir.c (_hurd_change_directory_port_from_name):
Return ENOENT when name is empty.
* sysdeps/mach/hurd/chroot.c (chroot): Return ENOENT when path
is empty.
diff --git a/hurd/hurdchdir.c b/hurd/hurdchdir.c
index 5115e4d..b1cc7a5 100644
--- a/hurd/hurdchdir.c
+++ b/hurd/hurdchdir.c
@@ -38,6 +38,12 @@ _hurd_change_directory_port_from_name (struct hurd_port *portcell,
len = strlen (name);
if (len >= 2 && name[len - 2] == '/' && name[len - 1] == '.')
lookup = name;
+ else if (len == 0)
+ {
+ /* Special-case null pathname according to POSIX */
+ errno = ENOENT;
+ return -1;
+ }
else
{
char *n = alloca (len + 3);
diff --git a/sysdeps/mach/hurd/chroot.c b/sysdeps/mach/hurd/chroot.c
index fde0164..cabeb7d 100644
--- a/sysdeps/mach/hurd/chroot.c
+++ b/sysdeps/mach/hurd/chroot.c
@@ -38,6 +38,12 @@ chroot (const char *path)
len = strlen (path);
if (len >= 2 && path[len - 2] == '/' && path[len - 1] == '.')
lookup = path;
+ else if (len == 0)
+ {
+ /* Special-case null pathname according to POSIX */
+ errno = ENOENT;
+ return -1;
+ }
else
{
char *n = alloca (len + 3);
More information about the Libc-alpha
mailing list