From: Eric Blake Date: Sat, 5 Sep 2009 03:22:21 +0000 (-0600) Subject: openat: fail with ENOENT on empty name X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c46ae39631773a7fdae7d171cc4ef0bf2123efff;p=pspp openat: fail with ENOENT on empty name * lib/openat-proc.c (openat_proc_name): Special-case the empty buffer. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 193ec7f196..ecbf16e27f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-09-04 Eric Blake + 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 diff --git a/lib/openat-proc.c b/lib/openat-proc.c index 8057033e86..76e1c6dd51 100644 --- a/lib/openat-proc.c +++ b/lib/openat-proc.c @@ -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