diff options
author | nectar <nectar@FreeBSD.org> | 2003-04-20 01:12:00 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2003-04-20 01:12:00 +0000 |
commit | ae503410da7b3c55dce4c45ca24e59b514c9ce5b (patch) | |
tree | 1ce29d8dafe38136f95ce7762769b143bc08b9d8 /lib/libc | |
parent | 920bae3858a66ddb5fe8d5ac8660cdbc00727388 (diff) | |
download | FreeBSD-src-ae503410da7b3c55dce4c45ca24e59b514c9ce5b.zip FreeBSD-src-ae503410da7b3c55dce4c45ca24e59b514c9ce5b.tar.gz |
Repair a bug in which a faulty group entry (one with only 2 colons)
would result in an incorrectly terminated grouplist.
login(1) crashes
Reported by: Morten Rodal <morten@rodal.no>,
Matthias Schuendehuette <msch@snafu.de>
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/getgrent.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index b268aac..ca95e55 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -500,7 +500,6 @@ files_group(void *retval, void *mdata, va_list ap) if (rv & NS_TERMINATE) break; } -fin: if (!stayopen && st->fp != NULL) { fclose(st->fp); st->fp = NULL; @@ -1083,7 +1082,7 @@ int __gr_parse_entry(char *line, size_t linesize, struct group *grp, char *membuf, size_t membufsize, int *errnop) { - char *s_gid, *s_mem, **members; + char *s_gid, *s_mem, *p, **members; unsigned long n; int maxmembers; @@ -1104,13 +1103,12 @@ __gr_parse_entry(char *line, size_t linesize, struct group *grp, char *membuf, return (NS_NOTFOUND); grp->gr_gid = (gid_t)n; grp->gr_mem = members; - if (s_mem[0] == '\0') { - *members = NULL; - return (NS_SUCCESS); - } while (maxmembers > 1 && s_mem != NULL) { - *members++ = strsep(&s_mem, ","); - maxmembers--; + p = strsep(&s_mem, ","); + if (p != NULL && *p != '\0') { + *members++ = p; + maxmembers--; + } } *members = NULL; if (s_mem == NULL) |