summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-02-28 23:23:16 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2021-03-01 00:18:44 -0800
commit55f2a0772e08b9febac3ac0de5cb048d4c60d2f5 (patch)
tree392c30ce4b70ba1431f0bd6d5ec35223cd632a68
parentdaf634c44e2714c7525e6c552c5a5adc87cba887 (diff)
downloadtar-55f2a0772e08b9febac3ac0de5cb048d4c60d2f5.tar.gz
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'.
-rw-r--r--src/sparse.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/sparse.c b/src/sparse.c
index 61561f45..22ba32fa 100644
--- a/src/sparse.c
+++ b/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;