"rcmd" makes a bad assumption about null pointers
Guy Harris
guy%gorodish at Sun.COM
Thu Jan 15 07:25:13 AEST 1987
Index: lib/libc/net/rcmd.c 4.3BSD
Description:
"rcmd" assumes that ((char *)NULL + 1) == (char *)1. This
may happen to be true on both machines, but it is not guaranteed
to be true.
Repeat-By:
Read the code, preferably with air-sickness bag handy.
Fix:
*** /arch/4.3/usr/src/lib/libc/net/rcmd.c Tue May 6 14:35:22 1986
--- rcmd.c Wed Jan 14 13:19:38 1987
***************
*** 270,275 ****
--- 270,276 ----
{
static char ldomain[MAXHOSTNAMELEN + 1];
static char *domainp = NULL;
+ static int nodomain = 0;
register char *cp;
if (len == -1)
***************
*** 280,285 ****
--- 281,288 ----
return(1);
if (*(lhost + len) != '\0')
return(0);
+ if (nodomain)
+ return(0);
if (!domainp) {
if (gethostname(ldomain, sizeof(ldomain)) == -1) {
domainp = (char *)1;
***************
*** 286,293 ****
return(0);
}
ldomain[MAXHOSTNAMELEN] = NULL;
! if ((domainp = index(ldomain, '.') + 1) == (char *)1)
return(0);
cp = domainp;
while (*cp) {
*cp = isupper(*cp) ? tolower(*cp) : *cp;
--- 289,299 ----
return(0);
}
ldomain[MAXHOSTNAMELEN] = NULL;
! if ((domainp = index(ldomain, '.')) == (char *)NULL) {
! nodomain = 1;
return(0);
+ }
+ domainp++;
cp = domainp;
while (*cp) {
*cp = isupper(*cp) ? tolower(*cp) : *cp;
***************
*** 294,300 ****
cp++;
}
}
- if (domainp == (char *)1)
- return(0);
return(!strcmp(domainp, rhost + len +1));
}
--- 300,304 ----
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list