changeset 11950:bc28631dbf94

openat: fail with ENOENT on empty name * lib/openat-proc.c (openat_proc_name): Special-case the empty buffer. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Fri, 04 Sep 2009 21:22:21 -0600
parents 245de403ed19
children 5bb7bec3987e
files ChangeLog lib/openat-proc.c
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/lib/openat-proc.c
+++ b/lib/openat-proc.c
@@ -57,6 +57,13 @@
 {
   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