tar: improve diagnostic for truncated archive

* src/buffer.c (seek_archive): If EOF has been read, don’t attempt
to seek past it.  This replaces a bogus "rmtlseek not stopped at a
record boundary" message with a better "Unexpected EOF in archive"
when I run ‘tar tvf gtar13c.tar’ using the gtar13.tar file here:
https://lists.gnu.org/r/bug-tar/2024-03/msg00001.html
This commit is contained in:
Paul Eggert
2024-03-03 13:17:32 -08:00
parent fac2b4c11a
commit 21318f3856

View File

@@ -1072,6 +1072,11 @@ seek_archive (off_t size)
off_t start = current_block_ordinal (); off_t start = current_block_ordinal ();
off_t offset; off_t offset;
off_t nrec, nblk; off_t nrec, nblk;
/* If low level I/O is already at EOF, do not try to seek further. */
if (record_end < record_start + blocking_factor)
return 0;
off_t skipped = (blocking_factor - (current_block - record_start)) off_t skipped = (blocking_factor - (current_block - record_start))
* BLOCKSIZE; * BLOCKSIZE;