[BusyBox] Bug in tar

Francois-R Boyer boyerf at IRO.UMontreal.CA
Sat Jan 20 04:54:19 UTC 2001


If we don't use the "if(errno == EPIPE) return;" we can make tar so that it does not break
the pipe.
Remove all close(tarFd) from readTarFile, and the code to wait for the child would become:
        if (unzipFlag == TRUE)
        {
            char buf[4096];
            while(waitpid(child_pid, NULL, WNOHANG) == 0) read(tarFd,buf,sizeof(buf));
        }

If we don't read what comes from the pipe, the child will block when the pipe buffer is
full.  I agree that ignoring EPIPE was not the best solution, but it was better than leaving
it the way it was.  This new solution is better, and no changes are made to gunzip.

    François

Glenn McGrath wrote:

> Francois-R Boyer wrote:
> >
> > What I can tell is that if you leave it the way it is (with the "signal(SIGCHLD,
> > child_died);") it often does a segmentation fault.  If you remove that line, it works
> > (the program terminates) with all the files I've tested, and I've tested also with
> > corrupted files.  But with corrupted files, no error message is displayed.
> >
> > If you want to handle correctly signals, have message displayed and terminate process
> > in the right order, you must:
> >   Continue decompression even if the pipe is broken, so that the correct "invalid
> > compressed data..." error is displayed.
> >   Wait for unzip to terminate before we exit tar, so that the error message is
> > displayed before the command prompt.
> >
> > How to do that:
> >
> >   in gunzip.c/write_buf:
> >     if (n == (unsigned) (-1)) {
> >         if(errno == EPIPE) return;    /* add this line, to ignore broken pipe error */
> >
> >         write_error_msg();
> >     }
> >
>
> What about handling a broken pipe when called from gunzip itself rather
> than from tar ?
>
> Glenn






More information about the busybox mailing list