]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
tar: improve diagnostic for truncated archive
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 3 Mar 2024 21:17:32 +0000 (13:17 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 3 Mar 2024 21:28:23 +0000 (13:28 -0800)
* 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

src/buffer.c

index 56273642bf63db3e4f7a7ae02a60d3e1edce436a..9da6747a6cf28a147eb4e882728fbf36eb566daa 100644 (file)
@@ -1072,6 +1072,11 @@ seek_archive (off_t size)
   off_t start = current_block_ordinal ();
   off_t offset;
   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))
                   * BLOCKSIZE;