Wes Hardaker wrote:
>>>>>> "TA" == Thomas Anders <[EMAIL PROTECTED]> writes:
> 
> TA> snmplib/system.c uses nlist() (and open(/dev/kmem), lseek and read)
> TA> without properly protecting the code by #ifdef NETSNMP_CAN_USE_NLIST.
> TA> Thus, this code is active even if --without-kmem-usage has been
> TA> specified (recommended in README.aix and README.irix for 64-bit builds),
> TA> which is a bug.
> 
> +1.  Sorry it took so long, but I wanted to review very carefully what
> happens when you don't have the symbols.  Previously we were falling
> into code, but with your patch we were falling beyond code and I
> wanted to look more closely to make sure that wasn't going to cause
> issues before I voted.  I've done so, and thus the +1...  Otherwise I
> was going to vote -1 ;-)

Unfortunately there has been a small, but significant mistake in my patch that
neither my testing nor the reviews revealed. snmplib/system.c now contains:

  #elif NETSNMP_CAN_USE_NLIST

at two places. This looks oh so logical given that there's "#elif
NETSNMP_CAN_USE_SYSCTL" nearby, but unfortunately net-snmp-config.h says:

#if defined(HAVE_NLIST) && defined(STRUCT_NLIST_HAS_N_VALUE) &&
!defined(NETSNMP_DONT_USE_NLIST) && !defined(NETSNMP_NO_KMEM_USAGE)
#define NETSNMP_CAN_USE_NLIST
#endif

so does *not* define a value for NETSNMP_CAN_USE_NLIST (unlike
NETSNMP_CAN_USE_SYSCTL or any other definition set by configure directly),
causing a compiler error like

system.c:699:28: #if with no expression
system.c:727:28: #if with no expression

on systems/configurations where NETSNMP_CAN_USE_NLIST is defined (to no value).

Thanks to Peter Eickel for catching it (see bug #1598927#1598966 for details),
thus offering us a chance to rectify this before the final release.

The attached trivial patch (a slightly modified variant of his proposed patch
#1598966) fixes this. I'm calling for votes to apply this before 5.4 final.


+Thomas

PS. I think we should change to "#define NETSNMP_CAN_USE_NLIST 1" for
consistency in net-snmp.config.h[.in] for 5.5 and later. Thoughts?

-- 
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.34
diff -u -p -r5.34 system.c
--- snmplib/system.c	16 Nov 2006 09:36:39 -0000	5.34
+++ snmplib/system.c	18 Nov 2006 22:35:33 -0000
@@ -696,7 +696,7 @@ get_boottime(void)
 #ifdef	NETSNMP_CAN_USE_SYSCTL
     int             mib[2];
     size_t          len;
-#elif NETSNMP_CAN_USE_NLIST
+#elif defined(NETSNMP_CAN_USE_NLIST)
     int             kmem;
     static struct nlist nl[] = {
 #if !defined(hpux)
@@ -724,7 +724,7 @@ get_boottime(void)
 
     sysctl(mib, 2, &boottime, &len, NULL, 0);
     boottime_csecs = (boottime.tv_sec * 100) + (boottime.tv_usec / 10000);
-#elif NETSNMP_CAN_USE_NLIST
+#elif defined(NETSNMP_CAN_USE_NLIST)
     if ((kmem = open("/dev/kmem", 0)) < 0)
         return 0;
     nlist(KERNEL_LOC, nl);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to