From c46ae39631773a7fdae7d171cc4ef0bf2123efff Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 4 Sep 2009 21:22:21 -0600 Subject: openat: fail with ENOENT on empty name * lib/openat-proc.c (openat_proc_name): Special-case the empty buffer. Signed-off-by: Eric Blake --- lib/openat-proc.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/openat-proc.c') 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 -- cgit v1.2.1