Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!rutgers!mit-eddie!genrad!decvax!decwrl!sun!gorodish!guy
From: guy%gorodish@Sun.COM (Guy Harris)
Newsgroups: comp.bugs.4bsd
Subject: "init" doesn't check for null pointers
Message-ID: <11393@sun.uucp>
Date: Wed, 14-Jan-87 07:43:55 EST
Article-I.D.: sun.11393
Posted: Wed Jan 14 07:43:55 1987
Date-Received: Thu, 15-Jan-87 03:26:46 EST
Sender: news@sun.uucp
Lines: 88

Index:	etc/init.c 4.3BSD

Description:
	When looking at the "ty_window" entry for a "ttyent" structure,
	"init" doesn't bother checking that "ty_window" is non-NULL.
	This may either cause core dumps or may cause it to erroneously
	conclude that a given entry has a window system program.
Repeat-By:
	Try running "init" on a machine where a NULL pointer, when treated
	as a character pointer and dereferenced, doesn't yield a null
	string.  Then try doing "kill -HUP 1"; it will get confused.
Fix:
Also includes a couple of other minor fixes.

*** /arch/4.3/usr/src/etc/init.c	Mon May 26 22:12:44 1986
--- init.c	Wed Jan 14 04:39:06 1987
***************
*** 144,150 ****
  	shutend();
  }
  
! char shutfailm[] = "WARNING: Something is hung (wont die); ps axl advised\n";
  
  shutreset()
  {
--- 144,150 ----
  	shutend();
  }
  
! char shutfailm[] = "WARNING: Something is hung (won't die); ps axl advised\n";
  
  shutreset()
  {
***************
*** 198,203 ****
--- 198,204 ----
  			dup2(0, 1);
  			dup2(0, 2);
  			execl(shell, minus, (char *)0);
+ 			perror(shell);
  			exit(0);
  		}
  		while ((xpid = wait((int *)0)) != pid)
***************
*** 306,312 ****
  				p->xflag |= CHANGE;
  				SCPYN(p->comn, t->ty_getty);
  			}
! 			if (SCMPN(p->wcmd, t->ty_window)) {
  				p->xflag |= WCHANGE|CHANGE;
  				SCPYN(p->wcmd, t->ty_window);
  			}
--- 307,313 ----
  				p->xflag |= CHANGE;
  				SCPYN(p->comn, t->ty_getty);
  			}
! 			if (SCMPN(p->wcmd, t->ty_window ? t->ty_window : "")) {
  				p->xflag |= WCHANGE|CHANGE;
  				SCPYN(p->wcmd, t->ty_window);
  			}
***************
*** 335,341 ****
  		SCPYN(p->line, t->ty_name);
  		p->xflag |= FOUND|CHANGE;
  		SCPYN(p->comn, t->ty_getty);
! 		if (strcmp(t->ty_window, "") != 0) {
  			p->xflag |= WCHANGE;
  			SCPYN(p->wcmd, t->ty_window);
  		}
--- 336,342 ----
  		SCPYN(p->line, t->ty_name);
  		p->xflag |= FOUND|CHANGE;
  		SCPYN(p->comn, t->ty_getty);
! 		if (t->ty_window && strcmp(t->ty_window, "") != 0) {
  			p->xflag |= WCHANGE;
  			SCPYN(p->wcmd, t->ty_window);
  		}
***************
*** 382,389 ****
  	if (p->wpid > 0)
  		kill(p->wpid, SIGHUP);
  }
- 
- #include 
  
  dfork(p)
  	struct tab *p;
--- 383,388 ----