[net.bugs.4bsd] bug in BSD cb

chris@pixutl.UUCP (chris) (10/02/86)

cb(1) doesn't check for EOF while handling comments and core dumps if comment
is non-terminated (some might say 'too bad', but...)

---------------------
REPEAT BY:

	% cat > /tmp/x
	/*
	^D
	% cb < /tmp/x

---------------------
FIX:		add the EOF test to the comment routine.

comment(){
rep:
	while((c = string[j++] = getch()) != '*')
		if(c == '\n'){
			puts();
			sflg = 1;
		}
		else if(c == EOF) {
			fprintf(stderr, "error: EOF in comment\n");
			exit(1);
		}
gotstar:
	if((c = string[j++] = getch()) != '/'){
		if(c == '*')goto gotstar;
		goto rep;
	}
}



-- 

 Chris Bertin       :  (603) 881-8791 x218
 xePIX Inc.         :
 51 Lake St         :  {allegra|ihnp4|cbosgd|ima|genrad|amd|harvard}\
 Nashua, NH 03060   :     !wjh12!pixel!pixutl!chris