bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] closed stderr can make tar corrupt its output archive


From: Jim Meyering
Subject: Re: [Bug-tar] closed stderr can make tar corrupt its output archive
Date: Sun, 28 Aug 2005 10:50:04 +0200

Sergey Poznyakoff <address@hidden> wrote:
> Hi Jim,
>
>>   - in --create mode, with a named target (i.e., not stdout),
>>   - with stderr closed, and
>>   - in a way that provokes tar to write a diagnostic,
>> then tar corrupts the named output archive by writing the diagnostic it.
>
> Thanks for reporting that. However I agree with Jörg that this is not a
> tar problem, and that a better fix would be to ensure in main that
> descriptors 0, 1, 2 be open.

Hi Sergey,

I've had the same reflex.  If you feel you must do that, then
consider lib/stdopen.c from coreutils cvs.  It is good enough
in the vast majority of cases:

http://savannah.gnu.org/cgi-bin/viewcvs/coreutils/coreutils/lib/stdopen.c?rev=HEAD&content-type=text/vnd.viewcvs-markup

BTW, it is not sufficient to ensure that they are open.
To be 100% faithful (in failing when any application tries to access
initially-closed file descriptors) an implementation must ensure
that *no* syscall operates successfully on the reopened file descriptors.
But afaik, that is not possible.  Hence, my preference to leave them closed.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]