From: Todd C. Miller Date: Wed, 12 Apr 2017 23:06:48 +0000 (-0600) Subject: In sudo_ttyname_scan() if dir is the empty string, set errno to X-Git-Tag: SUDO_1_8_20^2~47 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d989f8af30fe812bc87fc51f6e58c64c5baea17b;p=sudo In sudo_ttyname_scan() if dir is the empty string, set errno to ENOENT before returning. --- diff --git a/src/ttyname.c b/src/ttyname.c index 9b94ba8f1..21c013456 100644 --- a/src/ttyname.c +++ b/src/ttyname.c @@ -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,