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