summaryrefslogtreecommitdiff
path: root/src/passwd/getspnam.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-12-28 16:50:07 -0500
committerRich Felker <dalias@aerifal.cx>2018-12-28 16:50:07 -0500
commit9db81b862d95326d43af7c7fae9078ad9ff5bd6f (patch)
tree24f06e1891f50ea60eaedef456a16fa6eabb58d5 /src/passwd/getspnam.c
parent21a172dd36cae7a08492fd3a7500d7bf0daee13e (diff)
downloadmusl-9db81b862d95326d43af7c7fae9078ad9ff5bd6f.tar.gz
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.
Diffstat (limited to 'src/passwd/getspnam.c')
-rw-r--r--src/passwd/getspnam.c3
1 files changed, 2 insertions, 1 deletions
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;
}