Bug Report and Fix for more(UCB)

utzoo!decvax!duke!chico!harpo!houxf!ihnss!ucbvax!menlo70!hao!pag utzoo!decvax!duke!chico!harpo!houxf!ihnss!ucbvax!menlo70!hao!pag
Sat Nov 21 16:23:03 AEST 1981


There is a bug in "more" which raises its ugly head when the input
to more is a pipe, and a shell escape is performed.  The piped input
becomes piped to the shell escape causing all sorts of mysterious
results, at least when the shell escape reads standard input.
This problem commonly appears reading netnews.  The fix is simple --
if stdin is not from a tty, it must be closed before exec'ing the
shell escape.  The following code fragments come from the routine
execute():
------original code----
	if (id == 0) {
	    execv (cmd, &args);
	    write (2, "exec failed\n", 12);
	    exit (1);
	}
-----changed code----
	if (id == 0) {
	    /*
	     * Bug fix:  if stdin is a pipe, then it becomes input to
	     * cmd!  Fix by closing stdin, and dup'ing stderr
	     */
	    if(no_intty)
	    {
		close(0);
		dup(2);
	    }
	    execv (cmd, &args);
	    write (2, "exec failed\n", 12);
	    exit (1);
	}
--------------------
						--peter gross
						ucbvax!menlo70!hao!pag



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