Re: No hrSWRunPath in HOST-RESOURCES-MIB

Dave Shield <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
2009/3/31 Kamil Kisiel <[email protected]>:
> I decided to dive in to the source code of hr_swrun.c and found the
> following:

   [snip]

> It seems to me there's an error at line 746. Why is it checking to see if
> "cp" (presumably "char pointer") is NULL after reading a line in to "buf"?

Yup - I think you may well be correct.

> Should it not be checking if "buf" is NULL instead at this point?

That's not quite right, since 'buf' is a static buffer.
But could you please try the attached patch, and confirm
whether or not it fixes your problems.

Thanks

Dave

------------------------------------------------------------------------------

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
hrswrun.patch (text/x-patch, 629 B)
Index: agent/mibgroup/host/hr_swrun.c
===================================================================
--- agent/mibgroup/host/hr_swrun.c	(revision 17417)
+++ agent/mibgroup/host/hr_swrun.c	(working copy)
@@ -742,8 +742,7 @@
             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)) {
                 fclose(fp);
                 return NULL;    /* the process probably died */
             }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.