ID: 3058140

When the inode is zero, get_pid_from_inode will match it with invalid
file descriptors. It will therefor return pid 1 (init), because it is
the first to match with inode zero.  This patch checks the inode given
and returns a zero pid if the inode is also zero.

Obviously I'd fix the comment before applying.

--- agent/mibgroup/util_funcs/get_pid_from_inode.c  (revision 123786)
+++ agent/mibgroup/util_funcs/get_pid_from_inode.c  (working copy)
@@ -33,6 +33,11 @@
     pid_t           pid = 0;
     ino64_t         temp_inode;
 
+    if (inode == 0) {
+        // an inode set to zero means it is not associated with a process.
+        return 0;
+    }
+
     if (!(procdirs = opendir(PROC_PATH))) {
         snmp_log(LOG_ERR, "snmpd: cannot open /proc\n");
         return 0;


-- 
Wes Hardaker
Please mail all replies to net-snmp-coders@lists.sourceforge.net

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to