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

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