Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 20db51d70e6b59a061db97ce9b89c771 > files > 34

net-snmp-5.3.2.2-14.el5.src.rpm

Written-By: Jan Safranek <jsafrane@redhat.com>
Reviewed-By: Radek Vokal <rvokal@redhat.com>

Index: include/net-snmp/library/tools.h
===================================================================
--- include/net-snmp/library/tools.h	(revision 16735)
+++ include/net-snmp/library/tools.h	(working copy)
@@ -88,6 +88,17 @@
     Computers the minimum of a and b. */
 #define SNMP_MIN(a,b) ((a) > (b) ? (b) : (a))
 
+/** @def SNMP_MACRO_VAL_TO_STR(s)
+ *  Expands to string with value of the s. 
+ *  If s is macro, the resulting string is value of the macro.
+ *  Example: 
+ *   #define TEST 1234
+ *   SNMP_MACRO_VAL_TO_STR(TEST) expands to "1234"
+ *   SNMP_MACRO_VAL_TO_STR(TEST+1) expands to "1234+1"
+ */
+#define SNMP_MACRO_VAL_TO_STR(s) SNMP_MACRO_VAL_TO_STR_PRIV(s)  
+#define SNMP_MACRO_VAL_TO_STR_PRIV(s) #s
+	
 #ifndef FALSE
 #define FALSE 0
 #endif
Index: agent/mibgroup/ip-mib/data_access/ipaddress_linux.c
===================================================================
--- agent/mibgroup/ip-mib/data_access/ipaddress_linux.c	(revision 16735)
+++ agent/mibgroup/ip-mib/data_access/ipaddress_linux.c	(working copy)
@@ -189,7 +189,8 @@
     return -1;
 #else
     FILE           *in;
-    char            line[80], addr[40], if_name[IFNAMSIZ];
+    char            line[80], addr[40];
+    char            if_name[IFNAMSIZ+1];/* +1 for '\0' because of the ugly sscanf below */ 
     u_char          *buf;
     int             if_index, pfx_len, scope, flags, rc = 0;
     size_t          in_len, out_len;
@@ -229,7 +230,7 @@
          * F: flags (see include/linux/rtnetlink.h, net/ipv6/addrconf.c)
          * I: interface
          */
-        rc = sscanf(line, "%39s %02x %02x %02x %02x %8s\n",
+        rc = sscanf(line, "%39s %02x %02x %02x %02x %" SNMP_MACRO_VAL_TO_STR(IFNAMSIZ) "s\n",
                     addr, &if_index, &pfx_len, &scope, &flags, if_name);
         if( 6 != rc ) {
             snmp_log(LOG_ERR, PROCFILE " data format error (%d!=6), line ==|%s|\n",