From 9db81b862d95326d43af7c7fae9078ad9ff5bd6f Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 28 Dec 2018 16:50:07 -0500 Subject: don't set errno or return an error when getspnam[_r] finds no entry this case is specified as success with a null result, rather than an error, and errno is not to be set on success. --- src/passwd/getspnam.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/passwd/getspnam.c') diff --git a/src/passwd/getspnam.c b/src/passwd/getspnam.c index 041f8965..709b526d 100644 --- a/src/passwd/getspnam.c +++ b/src/passwd/getspnam.c @@ -8,10 +8,11 @@ struct spwd *getspnam(const char *name) static char *line; struct spwd *res; int e; + int orig_errno = errno; if (!line) line = malloc(LINE_LIM); if (!line) return 0; e = getspnam_r(name, &sp, line, LINE_LIM, &res); - if (e) errno = e; + errno = e ? e : orig_errno; return res; } -- cgit v1.2.1