From 58135fbd8b68228678eb0ce38566aaf7ab1aad94 Mon Sep 17 00:00:00 2001 From: Eric van Gyzen Date: Thu, 24 Feb 2022 17:00:52 -0600 Subject: [PATCH] gzip: fix error handling in unxz The result of fstat() was not checked. Furthermore, there was a redundant check of st.st_size. Fix both. Reported by: Coverity MFC after: 1 week Sponsored by: Dell EMC Isilon --- usr.bin/gzip/unxz.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr.bin/gzip/unxz.c b/usr.bin/gzip/unxz.c index b92bec8f39b0..246600fd657c 100644 --- a/usr.bin/gzip/unxz.c +++ b/usr.bin/gzip/unxz.c @@ -260,8 +260,7 @@ parse_indexes(xz_file_info *xfi, int src_fd) { struct stat st; - fstat(src_fd, &st); - if (st.st_size <= 0) { + if (fstat(src_fd, &st) != 0) { return true; }