openat: fail with ENOENT on empty name
authorEric Blake <ebb9@byu.net>
Sat, 5 Sep 2009 03:22:21 +0000 (21:22 -0600)
committerEric Blake <ebb9@byu.net>
Sat, 5 Sep 2009 03:26:36 +0000 (21:26 -0600)
* lib/openat-proc.c (openat_proc_name): Special-case the empty
buffer.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/openat-proc.c

index 193ec7f..ecbf16e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2009-09-04  Eric Blake  <ebb9@byu.net>
 
+       openat: fail with ENOENT on empty name
+       * lib/openat-proc.c (openat_proc_name): Special-case the empty
+       buffer.
+
        link-follow: fix logic bug in prior patch
        * m4/link-follow.m4 (gl_FUNC_LINK_FOLLOWS_SYMLINK): Fix bug that
        reversed sense of yes and no in prior patch.  Avoid confusing
index 8057033..76e1c6d 100644 (file)
@@ -57,6 +57,13 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file)
 {
   static int proc_status = 0;
 
+  /* Make sure the caller gets ENOENT when appropriate.  */
+  if (!*file)
+    {
+      buf[0] = '\0';
+      return buf;
+    }
+
   if (! proc_status)
     {
       /* Set PROC_STATUS to a positive value if /proc/self/fd is