Article View: comp.bugs.4bsd
Article #470"rcmd" makes a bad assumption about null pointers
From: Guy Harris
Date: Wed, 14 Jan 1987 21:25
Date: Wed, 14 Jan 1987 21:25
64 lines
2029 bytes
2029 bytes
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 ----
Technical Details
Message-ID:
<11438@sun.uucp>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!cmcl2!husc6!mit-eddie!genrad!decvax!decwrl!sun!gorodish!guyShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!cmcl2!husc6!mit-eddie!genrad!decvax!decwrl!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.bugs.4bsd Subject: "rcmd" makes a bad assumption about null pointers Message-ID: <11438@sun.uucp> Date: Wed, 14-Jan-87 16:25:13 EST Article-I.D.: sun.11438 Posted: Wed Jan 14 16:25:13 1987 Date-Received: Thu, 15-Jan-87 21:37:39 EST Sender: news@sun.uucp Lines: 64