On Fri, Apr 4, 2014 at 11:27 AM, Marco Pfatschbacher <m...@mailq.de> wrote: > On Thu, Apr 03, 2014 at 05:19:45PM -0600, Theo de Raadt wrote: >> Interesting. Can we take bath approaches? > > I don't see why we should not. > >> Is there a reason to not expose either error? > > I thought it might break some legacy stuff regarding > tapes and such. But since no one spoke up... > > OK? > >> > pax does not exit with an error if the processed >> > archive is truncated: >> > >> > # (cd / && tar zcf - bsd | dd count=128 2>/dev/null | tar tzf -) >> > bsd >> > gzip: stdin: Input/output error >> > tar: End of archive volume 1 reached >> > gzip: stdout: Broken pipe >> > tar: Failed write to archive volume: 1: Broken pipe >> > # echo $? >> > 0 >> > >> > >> > There's two ways to fix this. >> > 1) take the exit code of gzip into account: >> > >> > Index: ar_io.c >> > =================================================================== >> > RCS file: /cvs/src/bin/pax/ar_io.c,v >> > retrieving revision 1.44 >> > diff -u -p -p -u -r1.44 ar_io.c >> > --- ar_io.c 11 Jan 2014 05:36:26 -0000 1.44 >> > +++ ar_io.c 28 Mar 2014 14:09:37 -0000 >> > @@ -337,8 +337,11 @@ ar_close(void) >> > (void)close(arfd); >> > >> > /* Do not exit before child to ensure data integrity */ >> > - if (zpid > 0) >> > + if (zpid > 0) { >> > waitpid(zpid, &status, 0); >> > + if (WIFEXITED(status) && WEXITSTATUS(status)) >> > + exit_val = 1; >> > + }
Hmm, should that be if (!WIFEXITED(status) || WEXITSTATUS(status)) >> > >> > if (vflag && (artyp == ISTAPE)) { >> > (void)fputs("done.\n", listf); >> > >> > 2) >> > call paxwarn with 1 on truncated reads. >> > Which will also work for non-gzipped tar files. >> > >> > Index: ar_io.c >> > =================================================================== >> > RCS file: /cvs/src/bin/pax/ar_io.c,v >> > retrieving revision 1.44 >> > diff -u -p -p -u -r1.44 ar_io.c >> > --- ar_io.c 11 Jan 2014 05:36:26 -0000 1.44 >> > +++ ar_io.c 3 Apr 2014 22:04:07 -0000 >> > @@ -567,7 +570,7 @@ ar_read(char *buf, int cnt) >> > if (res < 0) >> > syswarn(1, errno, "Failed read on archive volume %d", arvol); >> > else >> > - paxwarn(0, "End of archive volume %d reached", arvol); >> > + paxwarn(1, "End of archive volume %d reached", arvol); >> > return(res); >> > } >> > >> > Is there a historic reason for this? >> > >> >