-Coders,

snmplib/system.c uses nlist() (and open(/dev/kmem), lseek and read)
without properly protecting the code by #ifdef NETSNMP_CAN_USE_NLIST.
Thus, this code is active even if --without-kmem-usage has been
specified (recommended in README.aix and README.irix for 64-bit builds),
which is a bug.

The attached patch fixes this. I'm calling for votes to include this in 5.4.

Note1: This issue hasn't been catched before because the code doesn't
use NETSNMP_KLOOKUP like everything else -- to be cleaned up after 5.4.

Note2: I suggest to review the resulting code rather than the patch,
because I find it easier to read. YMMV, of course.


+Thomas

-- 
Thomas Anders (thomas.anders at blue-cable.de)
Index: snmplib/system.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/snmplib/system.c,v
retrieving revision 5.33
diff -u -p -r5.33 system.c
--- snmplib/system.c	15 Sep 2006 14:14:20 -0000	5.33
+++ snmplib/system.c	13 Nov 2006 15:07:47 -0000
@@ -696,7 +696,7 @@ get_boottime(void)
 #ifdef	NETSNMP_CAN_USE_SYSCTL
     int             mib[2];
     size_t          len;
-#else
+#elif NETSNMP_CAN_USE_NLIST
     int             kmem;
     static struct nlist nl[] = {
 #if !defined(hpux)
@@ -716,8 +716,7 @@ get_boottime(void)
 #if defined(hpux10) || defined(hpux11)
     pstat_getstatic(&pst_buf, sizeof(struct pst_static), 1, 0);
     boottime_csecs = pst_buf.boot_time * 100;
-#else
-#ifdef NETSNMP_CAN_USE_SYSCTL
+#elif NETSNMP_CAN_USE_SYSCTL
     mib[0] = CTL_KERN;
     mib[1] = KERN_BOOTTIME;
 
@@ -725,7 +724,7 @@ get_boottime(void)
 
     sysctl(mib, 2, &boottime, &len, NULL, 0);
     boottime_csecs = (boottime.tv_sec * 100) + (boottime.tv_usec / 10000);
-#else                           /* NETSNMP_CAN_USE_SYSCTL */
+#elif NETSNMP_CAN_USE_NLIST
     if ((kmem = open("/dev/kmem", 0)) < 0)
         return 0;
     nlist(KERNEL_LOC, nl);
@@ -738,7 +737,8 @@ get_boottime(void)
     read(kmem, &boottime, sizeof(boottime));
     close(kmem);
     boottime_csecs = (boottime.tv_sec * 100) + (boottime.tv_usec / 10000);
-#endif                          /* NETSNMP_CAN_USE_SYSCTL */
+#else
+    return 0;
 #endif                          /* hpux10 || hpux 11 */
 
     return (boottime_csecs);
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to