mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
fix erroneous return of partial username matches by getspnam[_r]
when using /etc/shadow (rather than tcb) as its backend, getspnam_r matched any username starting with the caller-provided string rather than requiring an exact match. in practice this seems to have affected only systems where one valid username is a prefix for another valid username, and where the longer username appears first in the shadow file.
This commit is contained in:
parent
63cac4e29a
commit
ecb608192a
1 changed files with 1 additions and 1 deletions
|
@ -98,7 +98,7 @@ int getspnam_r(const char *name, struct spwd *sp, char *buf, size_t size, struct
|
|||
|
||||
pthread_cleanup_push(cleanup, f);
|
||||
while (fgets(buf, size, f) && (k=strlen(buf))>0) {
|
||||
if (skip || strncmp(name, buf, l)) {
|
||||
if (skip || strncmp(name, buf, l) || buf[l]!=':') {
|
||||
skip = buf[k-1] != '\n';
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue