Skip to content

Commit

Permalink
libnss_mxshadow: Return errno in errnop, too
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
donald committed May 7, 2021
1 parent e1f00f1 commit 6441fa8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libnss_mxshadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 6441fa8

Please sign in to comment.