FIXED: numerous bugs in src/chessclock.c

utzoo!decvax!ucbvax!dist2 utzoo!decvax!ucbvax!dist2
Mon Dec 7 03:42:37 AEST 1981


	In addition to not properly dealing with UCB buffered i/o, this
program did raw terminal i/o without properly stripping the eighth bit
off characters read, and always used sh to execute shell escapes
instead of inspecting the environment for a ``SHELL'' variable.  The
necessary fixes are:

	diff src/chessclock.c.old src/chessclock.c
	85a86
	> 	fflush (stdout);
	99a101
	> 	fflush (stdout);
	105a108,110
	> #ifndef	V6
	> 	char	myshell[BUFSIZ], *shellptr;
	> 	char	*strcat (), *strncpy (), *getenv ();
	106a112,114
	> 	myshell[0]	= '\0';
	> 	shellptr	= (char *) NULL;
	> #endif	V6
	113c121
	< 		switch (c) {
	---
	> 		switch (c & 0177) {
	121a130
	> 			fflush (stdout);
	129a139
	> 				fflush (stdout);
	147a158,165
	> #ifndef	V6
	> 			if (shellptr == (char *) NULL)	{
	> 				if ((shellptr = getenv ("SHELL")) == (char *) NULL)
	> 					shellptr	= "/bin/sh";
	> 				strncpy (myshell, shellptr, sizeof (myshell) - strlen (shellptr) - 4);
	> 			}
	> 			strcat (myshell, " -t");
	> #endif	V6
	152c170,175
	< 			system("sh -t");
	---
	> 			fflush (stdout);
	> #ifndef	V6
	> 			system (myshell);
	> #else
	> 			system ("sh -t");
	> #endif	V6
	154a178
	> 			fflush (stdout);
	186a211
	> 	fflush (stdout);
	221a247
	> 	fflush (stdout);

These changes should be made on all tapes written before 12/8/81.

			Carl



More information about the Comp.bugs.2bsd mailing list