4
0
Эх сурвалжийг харах

Fix unlikely uninitalized var bug with sparse file

* 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'.
Paul Eggert 4 жил өмнө
parent
commit
55f2a0772e
1 өөрчлөгдсөн 4 нэмэгдсэн , 1 устгасан
  1. 4 1
      src/sparse.c

+ 4 - 1
src/sparse.c

@@ -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;