]> granicus.if.org Git - sudo/commitdiff
In sudo_ttyname_scan() if dir is the empty string, set errno to
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 12 Apr 2017 23:06:48 +0000 (17:06 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 12 Apr 2017 23:06:48 +0000 (17:06 -0600)
ENOENT before returning.

src/ttyname.c

index 9b94ba8f1976f42a9f5ec4e4957a82062ca8e61f..21c01345688b7e5d81d7870b42ca527a75a2279c 100644 (file)
@@ -180,7 +180,11 @@ sudo_ttyname_scan(const char *dir, dev_t rdev, bool builtin, char *name, size_t
     DIR *d = NULL;
     debug_decl(sudo_ttyname_scan, SUDO_DEBUG_UTIL)
 
-    if (dir[0] == '\0' || (d = opendir(dir)) == NULL)
+    if (dir[0] == '\0') {
+       errno = ENOENT;
+       goto done;
+    }
+    if ((d = opendir(dir)) == NULL)
        goto done;
 
     sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,