File net-snmp-5.4.x_empty-process-status-file.patch of Package net-snmp

From: David Shield
Subject: snmpd doesn't report hrSWRunPath for processes other than init
References: bnc#486270, bnc#565586
Patch-mainline: r17460

Proper check for empty process status file, avoiding truncated walk of
hrSWRunPath.

Signed-off-by: Leonardo Chiquitto <lchiquitto@suse.de>

---
 hr_swrun.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: agent/mibgroup/host/hr_swrun.c
===================================================================
--- agent.orig/mibgroup/host/hr_swrun.c
+++ agent/mibgroup/host/hr_swrun.c
@@ -742,8 +742,7 @@ var_hrswrun(struct variable * vp,
             sprintf(string, "/proc/%d/status", pid);
             if ((fp = fopen(string, "r")) == NULL)
                 return NULL;
-            fgets(buf, sizeof(buf), fp);        /* Name: process name */
-            if ( cp == NULL ) {
+            if(!fgets(buf, sizeof(buf), fp)) {        /* Name: process name */
                 fclose(fp);
                 return NULL;    /* the process probably died */
             }
openSUSE Build Service is sponsored by