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

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