Re: [hackers] Re: [sbase][PATCH] fix tar short reads from pipes

From: Michael Forney <mforney_AT_mforney.org>
Date: Fri, 3 Feb 2017 14:44:13 -0800

On Fri, Feb 3, 2017 at 9:35 AM, willy <willy_AT_mailoo.org> wrote:
> Willy Gfn wrote:
>> Hello,
>>
>> The attached patch makes tar read again from a pipe in case less bytes
>> are read than expected.
>> This prevent a bug where it fails to extract files correctly because
>> not enough bytes are read from, eg, a pipe hooked to a decompression
>> program.
>
> Just realised there is a bug in my patch. We should only keep reading
> if read() returns more than 0 bytes, otherwise the functions returns.
>
> Updated patch attached.

If there is EINTR, s will be decremented by 1 incorrectly since r will
be -1. I think you need to move s += r to after the if (r < 0). But, I
don't think you could even get EINTR since tar doesn't set any signal
handlers. Maybe there is some case I don't know about though.
Received on Fri Feb 03 2017 - 23:44:13 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 03 2017 - 23:48:19 CET