Blame SOURCES/bz1196068-3-fence_kdump-add_monitor.patch

e4ffb1
From 67d1a3ea5d12b1a9f6ff222b55f42b3536a8a745 Mon Sep 17 00:00:00 2001
e4ffb1
From: Marek 'marx' Grac <mgrac@redhat.com>
e4ffb1
Date: Mon, 2 Mar 2015 10:58:06 +0100
e4ffb1
Subject: [PATCH 08/10] fence_kdump: Fix possible problems according to
e4ffb1
 Coverity
e4ffb1
e4ffb1
Previously, there was issue detected by Coverity. They do not matter too much
e4ffb1
because we care only about return value and it will not be 0 if program crash.
e4ffb1
But it is always better to have clean code, so fixing.
e4ffb1
e4ffb1
Resolves: rhbz#1196068
e4ffb1
---
e4ffb1
 fence/agents/kdump/fence_kdump.c | 21 +++++++++++----------
e4ffb1
 1 file changed, 11 insertions(+), 10 deletions(-)
e4ffb1
e4ffb1
diff --git a/fence/agents/kdump/fence_kdump.c b/fence/agents/kdump/fence_kdump.c
e4ffb1
index 29abbda..781df64 100644
e4ffb1
--- a/fence/agents/kdump/fence_kdump.c
e4ffb1
+++ b/fence/agents/kdump/fence_kdump.c
e4ffb1
@@ -118,21 +118,22 @@ do_action_monitor (void)
e4ffb1
 {
e4ffb1
     const char cmdline_path[] = "/proc/cmdline";
e4ffb1
     FILE *procFile;
e4ffb1
-    size_t sz;
e4ffb1
-    char *lines;
e4ffb1
-    int result;
e4ffb1
+    size_t sz = 0;
e4ffb1
+    char *lines = NULL;
e4ffb1
+    int result = 1;
e4ffb1
 
e4ffb1
     procFile = fopen(cmdline_path, "r");
e4ffb1
-    sz = 0;
e4ffb1
 
e4ffb1
-    while (!feof (procFile)) {
e4ffb1
-        getline (&lines, &sz, procFile);
e4ffb1
+    if (procFile == NULL) {
e4ffb1
+        log_error (0, "Unable to open file %s (%s)\n", cmdline_path, strerror (errno));
e4ffb1
+        return 1;
e4ffb1
     }
e4ffb1
 
e4ffb1
-    if (strstr(lines, "crashkernel=") == NULL) {
e4ffb1
-        result = 1;
e4ffb1
-    } else {
e4ffb1
-        result = 0;
e4ffb1
+    while (!feof (procFile)) {
e4ffb1
+        ssize_t rv = getline (&lines, &sz, procFile);
e4ffb1
+        if ((rv != -1) && (strstr(lines, "crashkernel=") != NULL)) {
e4ffb1
+            result = 0;
e4ffb1
+        }
e4ffb1
     }
e4ffb1
 
e4ffb1
     free (lines);
e4ffb1
-- 
e4ffb1
1.9.3
e4ffb1