[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tar doesn't handle short reads
From: |
Nikos Tsipinakis |
Subject: |
Re: Tar doesn't handle short reads |
Date: |
Wed, 5 Aug 2020 21:47:37 +0300 |
On 04/08, Paul Eggert wrote:
> Simply switching from safe_read to full_read would lose an errno value if
> there's an I/O error, so that patch alone wouldn't suffice for GNU 'tar'.
Can you elaborate? I can't find a code path that loses the errno.
'full_read' breaks if safe_read returns an error (-1), preserving errno. It only
overwrites errno if read returns 0/EOF, which should never happen in
create_regular_file's case as we know the exact size of the file at the point,
so the only way it hits that path is if the file really shrunk.
size_t n_rw = safe_rw (fd, ptr, count);
if (n_rw == (size_t) -1)
break;
if (n_rw == 0)
{
errno = ZERO_BYTE_TRANSFER_ERRNO;
break;
}
Perhaps this has to do with some minute detail of how read works that I'm
unfamiliar with?