]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Fix possible NULL dereference (savannah bug #55369)
authorSergey Poznyakoff <gray@gnu.org>
Mon, 14 Jan 2019 13:22:09 +0000 (15:22 +0200)
committerSergey Poznyakoff <gray@gnu.org>
Mon, 14 Jan 2019 13:22:09 +0000 (15:22 +0200)
* src/sparse.c (pax_decode_header): Check return from find_next_block.

src/sparse.c

index 127364e7394c71c9533a6bb52e960c63670d3b83..d642a46384685bcd200c0b2e74e8895be958bbe1 100644 (file)
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
         {                                                         \
           set_next_block_after (b);                               \
            b = find_next_block ();                                 \
+           if (!b)                                                 \
+             FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
            src = b->buffer;                                        \
           endp = b->buffer + BLOCKSIZE;                           \
         }                                                         \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
       start = current_block_ordinal ();
       set_next_block_after (current_header);
       blk = find_next_block ();
+      if (!blk)
+        FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
       p = blk->buffer;
       COPY_BUF (blk,nbuf,p);
       if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))