Ahao.145
net.2bsd-bugs
utzoo!decvax!duke!chico!harpo!houxf!ihnss!ucbvax!menlo70!hao!pag
Sat Nov 21 16:23:03 1981
Bug Report and Fix for more(UCB)
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

-----------------------------------------------------------------
gopher://quux.org/ conversion by John Goerzen <[email protected]>
of http://communication.ucsd.edu/A-News/


This Usenet Oldnews Archive
article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.

2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.