From d989f8af30fe812bc87fc51f6e58c64c5baea17b Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 12 Apr 2017 17:06:48 -0600 Subject: [PATCH] In sudo_ttyname_scan() if dir is the empty string, set errno to ENOENT before returning. --- src/ttyname.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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, -- 2.40.0