[net.bugs.4bsd] csh "source -h" causes core dump

glenn@sun.uucp (Glenn C. Skinner) (07/08/86)

Index:	bin/csh/sh.c 4.3BSD

This bug report/fix applies to version 5.3 (3/29/86) of sh.c, which
is the version contained in the 4.3 distribution.

Description:
	Invoking the C shell builtin ~source" with the "-h" flag but with
	no argument causes a core dump on machines that object to null
	pointer dereferences.
Repeat-By:
	Invoke "source -h" from an interactive C shell.
Fix:
	The problem is dereferencing a null pointer in sh.c:dosource().
	Applying the following context diff cures the problem.  Your
	line numbers will differ.

		-- Glenn Skinner, SMI

------- sh.c -------
*** /tmp/da5325	Tue Jul  8 12:28:25 1986
--- sh.c	Thu Jul  3 13:03:00 1986
***************
*** 812,820 ****
  	char buf[BUFSIZ];
  
  	t++;
  	if (*t && eq(*t, "-h")) {
! 		t++;
  		hflg++;
  	}
  	(void) strcpy(buf, *t);
  	f = globone(buf);
--- 812,821 ----
  	char buf[BUFSIZ];
  
  	t++;
  	if (*t && eq(*t, "-h")) {
! 		if (*++t == NOSTR)
! 			bferr("No operand for -h flag");
  		hflg++;
  	}
  	(void) strcpy(buf, *t);
  	f = globone(buf);