summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1995-03-23 22:18:00 +0000
committerwpaul <wpaul@FreeBSD.org>1995-03-23 22:18:00 +0000
commitec2490897f576e1387cd3df823a5a08fc070bede (patch)
treecbb13de4e6015771e9945ad3fb823073740c93b4 /lib
parentfe78d93cbe52784abef6fc1c46d284522b64b7b9 (diff)
downloadFreeBSD-src-ec2490897f576e1387cd3df823a5a08fc070bede.zip
FreeBSD-src-ec2490897f576e1387cd3df823a5a08fc070bede.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/getpwent.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index 270eed0..452aa21 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 @@ unpack:
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 @@ unpack:
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;
OpenPOWER on IntegriCloud