From 6441fa8d320acf2daceafd3d7640d235428c04c6 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 7 May 2021 13:07:18 +0200 Subject: [PATCH] libnss_mxshadow: Return errno in errnop, too From the glibc manual: "Before the function returns with a failure code, the implementation should store the value of the local errno variable in the variable pointed to be errnop. This is important to guarantee the module working in statically linked programs. The stored value must not be zero." So do it. --- libnss_mxshadow.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libnss_mxshadow.c b/libnss_mxshadow.c index 5a048c3..b8f2487 100644 --- a/libnss_mxshadow.c +++ b/libnss_mxshadow.c @@ -28,17 +28,20 @@ enum nss_status _nss_mxshadow_getspnam_r(const char *name, struct spwd *spwd, ch int status = get_shadow_line_from_server_v2((char *)name, &line); if (status == -1) { + *errnop = errno; return NSS_STATUS_UNAVAIL; } size_t len = strlen(line); if (buflen < len+1) { errno = ERANGE; + *errnop = errno; return -1; } strcpy(buffer, line); if (buffer[0] == '\0') { errno = ENOENT; + *errnop = errno; return NSS_STATUS_NOTFOUND; }