Blame SOURCES/0015-coverity-Check-return-value-of-fstat-call-def31.patch

a6c909
From 78e0ba4ce8d2e31c67e026f32279ad9f46a387f5 Mon Sep 17 00:00:00 2001
a6c909
From: Martin Kutlak <mkutlak@redhat.com>
a6c909
Date: Mon, 20 Aug 2018 17:08:33 +0200
a6c909
Subject: [PATCH] coverity: Check return value of fstat call #def31
a6c909
a6c909
Signed-off-by: Martin Kutlak <mkutlak@redhat.com>
a6c909
---
a6c909
 src/lib/read_write.c | 4 ++--
a6c909
 1 file changed, 2 insertions(+), 2 deletions(-)
a6c909
a6c909
diff --git a/src/lib/read_write.c b/src/lib/read_write.c
a6c909
index 657adb0c..a2e76db0 100644
a6c909
--- a/src/lib/read_write.c
a6c909
+++ b/src/lib/read_write.c
a6c909
@@ -133,8 +133,8 @@ void* xmalloc_read(int fd, size_t *maxsz_p)
a6c909
     /* Estimate file size */
a6c909
     {
a6c909
         struct stat st;
a6c909
-        st.st_size = 0; /* in case fstat fails, assume 0 */
a6c909
-        fstat(fd, &st);
a6c909
+        if (fstat(fd, &st) != 0)
a6c909
+            st.st_size = 0; /* in case fstat fails, assume 0 */
a6c909
         /* /proc/N/stat files report st_size 0 */
a6c909
         /* In order to make such files readable, we add small const (4k) */
a6c909
         size = (st.st_size | 0xfff) + 1;
a6c909
-- 
a6c909
2.17.1
a6c909