From 353fefe325490cc210ecc0b72a1f4c7ecf0dbe43 Mon Sep 17 00:00:00 2001 From: Bill Paul Date: Thu, 23 Mar 1995 22:18:00 +0000 Subject: [PATCH] Very important sanity checks: today I clobbered all four NIS servers on my network because setnetgrent() was trying to do a lookup on group "". It seems that an attempt to do a yp_match() (and possible yp_next()) on a null or empty key causes Sun's ypserv in SunOS 4.1.3 to exit suddenly (and without warning). Our ypserv behaves badly in this situation too, thoush it doesn't appear to crash. In any event, getpwent, getnetgrent and yp_match() and yp_next() are now extra careful not to accidentally pass on null or empty arguments. Also made a small change to getpwent.c to allow +::::::::: wildcarding, which I had disabled previously. --- lib/libc/gen/getpwent.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 270eed019d97..452aa2165280 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -334,7 +334,8 @@ _createcaches() key.size = (sizeof(i)) + 1; if (__hashpw(&key)) { p = (struct _pw_cache *)malloc(sizeof (struct _pw_cache)); - setnetgrent(_pw_passwd.pw_name+2); + if (_pw_passwd.pw_name[1]) + setnetgrent(_pw_passwd.pw_name+2); namehead = NULL; while(getnetgrent(&host, &user, &domain)) { n = (struct _namelist *)malloc(sizeof (struct _namelist)); @@ -382,7 +383,8 @@ _createcaches() key.size = (sizeof(i)) + 1; if (__hashpw(&key)) { m = (struct _pw_cache *)malloc(sizeof (struct _pw_cache)); - setnetgrent(_pw_passwd.pw_name+2); + if (_pw_passwd.pw_name[1]) + setnetgrent(_pw_passwd.pw_name+2); namehead = NULL; while(getnetgrent(&host, &user, &domain)) { n = (struct _namelist *)malloc(sizeof (struct _namelist)); @@ -564,7 +566,7 @@ _getyppass(struct passwd *pw, const char *name, const char *map) while (m) { n = m->namelist; while (n) { - if (!strcmp(n->name, s)) { + if (!strcmp(n->name, s) || *n->name == '\0') { free(result); return (0); } @@ -578,7 +580,7 @@ _getyppass(struct passwd *pw, const char *name, const char *map) while (p) { n = p->namelist; while (n) { - if (!strcmp(n->name, s)) + if (!strcmp(n->name, s) || *n->name == '\0') bcopy((char *)&p->pw_entry, (char *)&_pw_passwd, sizeof(p->pw_entry)); n = n->next; @@ -653,7 +655,7 @@ _nextyppass(struct passwd *pw) while (m) { n = m->namelist; while (n) { - if (!strcmp(n->name, s)) { + if (!strcmp(n->name, s) || *n->name == '\0') { free(result); goto tryagain; } @@ -667,7 +669,7 @@ _nextyppass(struct passwd *pw) while (p) { n = p->namelist; while (n) { - if (!strcmp(n->name, s)) + if (!strcmp(n->name, s) || *n->name == '\0') bcopy((char *)&p->pw_entry, (char*)&_pw_passwd, sizeof(p->pw_entry)); n = n->next;