]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Fix unlikely uninitalized var bug with sparse file
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 Mar 2021 07:23:16 +0000 (23:23 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 Mar 2021 08:18:44 +0000 (00:18 -0800)
* src/sparse.c (sparse_extract_file): Set *SIZE to
stat.st_size so that the caller does not use *SIZE
when uninitalized.  Problem found with GCC 10 and
--enable-gcc-warnings CFLAGS='-O2 -flto -fanalyzer'.

src/sparse.c

index 61561f45101f310e05e13cc1430a526ac882c306..22ba32fa8983f7f81ab7fdf81fc67987772e20c0 100644 (file)
@@ -568,7 +568,10 @@ sparse_extract_file (int fd, struct tar_stat_info *st, off_t *size)
   size_t i;
 
   if (!tar_sparse_init (&file))
-    return dump_status_not_implemented;
+    {
+      *size = st->stat.st_size;
+      return dump_status_not_implemented;
+    }
 
   file.stat_info = st;
   file.fd = fd;