-Coders,
my former "rfv: build fix for --without-kmem-usage"
http://sourceforge.net/mailarchive/message.php?msg_id=37193353
raised objections wrt. klookup error handling in certain mib modules, so
I'm hereby proposing a modified patch that allows for
--without-kmem-usage *and* adds proper error handling to all
NETSNMP_KLOOKUP calls to be on the safe side.
The attached patch passed build testing (both with and without
--without-kmem-usage) on Linux, Solaris 2.6-10, AIX 4.x/5.x, HP-UX
10.x/11.x, IRIX 6.5 and Tru64 Unix 5.x. In particular, on my 64-bit AIX
5.3 box (with root access) --without-kmem-usage with the patch now
prevents the agent from hanging when walking ifTable which is what the
default build suffers from.
I'm calling for votes to include this patch in 5.4.rc2. I'll update
documentation with notes on --without-kmem-usage once the patch is in.
+Thomas
--
Thomas Anders (thomas.anders at blue-cable.de)
Index: agent/kernel.h
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/kernel.h,v
retrieving revision 5.6
diff -u -p -r5.6 kernel.h
--- agent/kernel.h 31 Oct 2006 20:35:58 -0000 5.6
+++ agent/kernel.h 5 Nov 2006 22:13:22 -0000
@@ -3,6 +3,8 @@
extern void init_kmem(const char *);
extern int klookup(unsigned long, char *, int);
#define NETSNMP_KLOOKUP(x,y,z) klookup((unsigned long) x,y,z)
+#else
+#define NETSNMP_KLOOKUP(x,y,z)
#endif
#if HAVE_KVM_H
Index: agent/mibgroup/mibII/at.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/mibII/at.c,v
retrieving revision 5.16
diff -u -p -r5.16 at.c
--- agent/mibgroup/mibII/at.c 16 Oct 2006 15:21:18 -0000 5.16
+++ agent/mibgroup/mibII/at.c 5 Nov 2006 22:13:23 -0000
@@ -776,8 +776,15 @@ ARP_Scan_Next(u_long * IPAddr, char *Phy
continue;
}
- NETSNMP_KLOOKUP(at_ptr, (char *) &at_entry, sizeof(struct arptab));
- NETSNMP_KLOOKUP(at_entry.at_ac, (char *) &at_com, sizeof(struct arpcom));
+ if (!NETSNMP_KLOOKUP(at_ptr, (char *) &at_entry, sizeof(struct arptab))) {
+ DEBUGMSGTL(("mibII/at:ARP_Scan_Next", "klookup failed\n"));
+ break;
+ }
+
+ if (!NETSNMP_KLOOKUP(at_entry.at_ac, (char *) &at_com, sizeof(struct arpcom))) {
+ DEBUGMSGTL(("mibII/at:ARP_Scan_Next", "klookup failed\n"));
+ break;
+ }
at_ptr = at_entry.at_next;
atab = &at_entry;
Index: agent/mibgroup/mibII/interfaces.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/mibII/interfaces.c,v
retrieving revision 5.46
diff -u -p -r5.46 interfaces.c
--- agent/mibgroup/mibII/interfaces.c 17 Oct 2006 17:39:15 -0000 5.46
+++ agent/mibgroup/mibII/interfaces.c 5 Nov 2006 22:13:23 -0000
@@ -1804,8 +1804,15 @@ Interface_Scan_Next(short *Index,
* Get the "ifnet" structure and extract the device name
*/
#ifndef linux
- NETSNMP_KLOOKUP(ifnetaddr, (char *) &ifnet, sizeof ifnet);
- NETSNMP_KLOOKUP(ifnet.if_name, (char *) saveName, sizeof saveName);
+ if (!NETSNMP_KLOOKUP(ifnetaddr, (char *) &ifnet, sizeof ifnet)) {
+ DEBUGMSGTL(("mibII/interfaces:Interface_Scan_Next", "klookup failed\n"));
+ break;
+ }
+
+ if (!NETSNMP_KLOOKUP(ifnet.if_name, (char *) saveName, sizeof saveName)) {
+ DEBUGMSGTL(("mibII/interfaces:Interface_Scan_Next", "klookup failed\n"));
+ break;
+ }
/*
* The purpose of this comparison is lost in the mists of time.
@@ -1925,16 +1932,25 @@ Interface_Scan_Next(short *Index,
/*
* Get the "ifnet" structure and extract the device name
*/
- NETSNMP_KLOOKUP(ifnetaddr, (char *) &ifnet, sizeof ifnet);
+ if (!NETSNMP_KLOOKUP(ifnetaddr, (char *) &ifnet, sizeof ifnet)) {
+ DEBUGMSGTL(("mibII/interfaces:Interface_Scan_Next", "klookup failed\n"));
+ break;
+ }
#if STRUCT_IFNET_HAS_IF_XNAME
#if defined(netbsd1) || defined(openbsd2)
strncpy(saveName, ifnet.if_xname, sizeof saveName);
#else
- NETSNMP_KLOOKUP(ifnet.if_xname, (char *) saveName, sizeof saveName);
+ if (!NETSNMP_KLOOKUP(ifnet.if_xname, (char *) saveName, sizeof saveName)) {
+ DEBUGMSGTL(("mibII/interfaces:Interface_Scan_Next", "klookup failed\n"));
+ break;
+ }
#endif
saveName[sizeof(saveName) - 1] = '\0';
#else
- NETSNMP_KLOOKUP(ifnet.if_name, (char *) saveName, sizeof saveName);
+ if (!NETSNMP_KLOOKUP(ifnet.if_name, (char *) saveName, sizeof saveName)) {
+ DEBUGMSGTL(("mibII/interfaces:Interface_Scan_Next", "klookup failed\n"));
+ break;
+ }
saveName[sizeof(saveName) - 1] = '\0';
cp = strchr(saveName, '\0');
@@ -1951,7 +1967,10 @@ Interface_Scan_Next(short *Index,
auto_nlist(IFADDR_SYMBOL, (char *) &ia, sizeof(ia));
#endif
while (ia) {
- NETSNMP_KLOOKUP(ia, (char *) &in_ifaddr, sizeof(in_ifaddr));
+ if (!NETSNMP_KLOOKUP(ia, (char *) &in_ifaddr, sizeof(in_ifaddr))) {
+ DEBUGMSGTL(("mibII/interfaces:Interface_Scan_Next", "klookup failed\n"));
+ break;
+ }
{
#ifdef netbsd1
#define CP(x) ((char *)(x))
@@ -2143,7 +2162,10 @@ Interface_Get_Ether_By_Index(int Index,
*/
#ifndef linux
#if !(defined(netbsd1) || defined(bsdi2) || defined(openbsd2))
- NETSNMP_KLOOKUP(saveifnetaddr, (char *) &arpcom, sizeof arpcom);
+ if (!NETSNMP_KLOOKUP(saveifnetaddr, (char *) &arpcom, sizeof arpcom)) {
+ DEBUGMSGTL(("mibII/interfaces:Interface_Get_Ether_By_Index", "klookup failed\n"));
+ return 0;
+ }
#else /* netbsd1 or bsdi2 or openbsd2 */
#if defined(netbsd1) || defined(openbsd2)
@@ -2153,8 +2175,14 @@ Interface_Get_Ether_By_Index(int Index,
ifaddraddr = (unsigned long) saveifnet.if_addrlist;
while (ifaddraddr) {
- NETSNMP_KLOOKUP(ifaddraddr, (char *) &ifaddr, sizeof ifaddr);
- NETSNMP_KLOOKUP(ifaddr.ifa_addr, (char *) &sadl, sizeof sadl);
+ if (!NETSNMP_KLOOKUP(ifaddraddr, (char *) &ifaddr, sizeof ifaddr)) {
+ DEBUGMSGTL(("mibII/interfaces:Interface_Get_Ether_By_Index", "klookup failed\n"));
+ break;
+ }
+ if (!NETSNMP_KLOOKUP(ifaddr.ifa_addr, (char *) &sadl, sizeof sadl)) {
+ DEBUGMSGTL(("mibII/interfaces:Interface_Get_Ether_By_Index", "klookup failed\n"));
+ break;
+ }
if (sadl.sdl_family == AF_LINK
&& (saveifnet.if_type == IFT_ETHER
|| saveifnet.if_type == IFT_ISO88025
Index: agent/mibgroup/mibII/ipAddr.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/mibII/ipAddr.c,v
retrieving revision 5.22
diff -u -p -r5.22 ipAddr.c
--- agent/mibgroup/mibII/ipAddr.c 14 Oct 2006 21:28:37 -0000 5.22
+++ agent/mibgroup/mibII/ipAddr.c 5 Nov 2006 22:13:23 -0000
@@ -384,7 +384,11 @@ Address_Scan_Next(Index, Retin_ifaddr)
/*
* Get the "in_ifaddr" structure
*/
- NETSNMP_KLOOKUP(in_ifaddraddr, (char *) &in_ifaddr, sizeof in_ifaddr);
+ if (!NETSNMP_KLOOKUP(in_ifaddraddr, (char *) &in_ifaddr, sizeof in_ifaddr)) {
+ DEBUGMSGTL(("mibII/ip:Address_Scan_Next", "klookup failed\n"));
+ return 0;
+ }
+
in_ifaddraddr = in_ifaddr.ia_next;
if (Retin_ifaddr)
@@ -397,7 +401,10 @@ Address_Scan_Next(Index, Retin_ifaddr)
auto_nlist(IFNET_SYMBOL, (char *) &ifnetaddr, sizeof(ifnetaddr));
while (ifnetaddr && ifnetaddr != in_ifaddr.ia_ifp) {
- NETSNMP_KLOOKUP(ifnetaddr, (char *) &ifnet, sizeof ifnet);
+ if (!NETSNMP_KLOOKUP(ifnetaddr, (char *) &ifnet, sizeof ifnet)) {
+ DEBUGMSGTL(("mibII/ip:Address_Scan_Next", "klookup failed\n"));
+ return 0;
+ }
ifnetaddr = ifnet.if_next;
iindex++;
}
Index: agent/mibgroup/mibII/ipv6.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/mibII/ipv6.c,v
retrieving revision 5.9
diff -u -p -r5.9 ipv6.c
--- agent/mibgroup/mibII/ipv6.c 14 Oct 2006 21:28:37 -0000 5.9
+++ agent/mibgroup/mibII/ipv6.c 5 Nov 2006 22:13:24 -0000
@@ -570,7 +570,10 @@ if_getifnet(int idx, struct ifnet *resul
if (!auto_nlist("ifnet", (char *) &q, sizeof(q)))
return -1;
while (q) {
- NETSNMP_KLOOKUP(q, (char *) &tmp, sizeof(tmp));
+ if (!NETSNMP_KLOOKUP(q, (char *) &tmp, sizeof(tmp))) {
+ DEBUGMSGTL(("mibII/ipv6:if_getifnet", "klookup failed\n"));
+ return -1;
+ }
if (idx == tmp.if_index) {
memcpy(result, &tmp, sizeof(tmp));
return 0;
@@ -816,8 +819,14 @@ var_ifv6Entry(register struct variable *
# endif
#endif
while (ifa) {
- NETSNMP_KLOOKUP(ifa, (char *) &ifaddr, sizeof(ifaddr));
- NETSNMP_KLOOKUP(ifaddr.ifa_addr, (char *) &sdl, sizeof(sdl));
+ if (!NETSNMP_KLOOKUP(ifa, (char *) &ifaddr, sizeof(ifaddr))) {
+ DEBUGMSGTL(("mibII/ipv6:var_ipv6", "klookup failed\n"));
+ break;
+ }
+ if (!NETSNMP_KLOOKUP(ifaddr.ifa_addr, (char *) &sdl, sizeof(sdl));
+ DEBUGMSGTL(("mibII/ipv6:var_ipv6", "klookup failed\n"));
+ break;
+ }
if (sdl.sdl_family == AF_LINK) {
if (sizeof(sdl.sdl_data) < sdl.sdl_nlen + sdl.sdl_alen) {
ERROR_MSG("sdl_alen too long for interface\n");
@@ -1284,7 +1293,7 @@ var_udp6(register struct variable * vp,
DEBUGMSGTL(("mibII/ipv6", "looping: p=%x\n", p));
#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
- if (NETSNMP_KLOOKUP(p, (char *) &in6pcb, sizeof(in6pcb)) < 0) {
+ if (!NETSNMP_KLOOKUP(p, (char *) &in6pcb, sizeof(in6pcb))) {
DEBUGMSGTL(("mibII/ipv6", "klookup fail for udb6 at %x\n",
p));
found = 0;
@@ -1474,7 +1483,7 @@ var_tcp6(register struct variable * vp,
DEBUGMSGTL(("mibII/ipv6", "looping: p=%x\n", p));
#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
- if (NETSNMP_KLOOKUP(p, (char *) &in6pcb, sizeof(in6pcb)) < 0) {
+ if (!NETSNMP_KLOOKUP(p, (char *) &in6pcb, sizeof(in6pcb))) {
DEBUGMSGTL(("mibII/ipv6", "klookup fail for tcb6 at %x\n",
p));
found = 0;
@@ -1490,8 +1499,7 @@ var_tcp6(register struct variable * vp,
if (0 == (in6pcb.inp_vflag & INP_IPV6))
goto skip;
#endif
- if (NETSNMP_KLOOKUP(in6pcb.in6p_ppcb, (char *) &tcp6cb, sizeof(tcp6cb))
- < 0) {
+ if (!NETSNMP_KLOOKUP(in6pcb.in6p_ppcb, (char *) &tcp6cb, sizeof(tcp6cb))) {
DEBUGMSGTL(("mibII/ipv6", "klookup fail for tcb6.tcp6cb at %x\n",
in6pcb.in6p_ppcb));
found = 0;
@@ -1697,7 +1705,7 @@ var_tcp6(register struct variable * vp,
DEBUGMSGTL(("mibII/ipv6", "looping: p=%x\n", p));
#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
- if (NETSNMP_KLOOKUP(p, (char *) &in6pcb, sizeof(in6pcb)) < 0) {
+ if (!NETSNMP_KLOOKUP(p, (char *) &in6pcb, sizeof(in6pcb))) {
DEBUGMSGTL(("mibII/ipv6", "klookup fail for tcb6 at %x\n",
p));
found = 0;
@@ -1713,8 +1721,7 @@ var_tcp6(register struct variable * vp,
if (0 == (in6pcb.inp_vflag & INP_IPV6))
goto skip;
#endif
- if (NETSNMP_KLOOKUP(in6pcb.in6p_ppcb, (char *) &tcpcb, sizeof(tcpcb))
- < 0) {
+ if (!NETSNMP_KLOOKUP(in6pcb.in6p_ppcb, (char *) &tcpcb, sizeof(tcpcb))) {
DEBUGMSGTL(("mibII/ipv6", "klookup fail for tcb6.tcpcb at %x\n",
in6pcb.in6p_ppcb));
found = 0;
Index: agent/mibgroup/mibII/tcpTable.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/mibII/tcpTable.c,v
retrieving revision 5.22
diff -u -p -r5.22 tcpTable.c
--- agent/mibgroup/mibII/tcpTable.c 14 Oct 2006 21:28:37 -0000 5.22
+++ agent/mibgroup/mibII/tcpTable.c 5 Nov 2006 22:13:24 -0000
@@ -789,8 +789,15 @@ tcpTable_load(netsnmp_cache *cache, void
nnew = SNMP_MALLOC_TYPEDEF(netsnmp_inpcb);
if (!nnew)
break;
- NETSNMP_KLOOKUP(entry, (char *)&(nnew->pcb), sizeof(struct inpcb));
- NETSNMP_KLOOKUP(nnew->pcb.inp_ppcb, (char *)&tcpcb, sizeof(struct tcpcb));
+ if (!NETSNMP_KLOOKUP(entry, (char *)&(nnew->pcb), sizeof(struct inpcb))) {
+ DEBUGMSGTL(("mibII/tcpTable:TcpTable_load", "klookup failed\n"));
+ break;
+ }
+
+ if (!NETSNMP_KLOOKUP(nnew->pcb.inp_ppcb, (char *)&tcpcb, sizeof(struct tcpcb))) {
+ DEBUGMSGTL(("mibII/tcpTable:TcpTable_load", "klookup failed\n"));
+ break;
+ }
nnew->state = StateMap[tcpcb.t_state];
if (nnew->state == 5 /* established */ ||
nnew->state == 8 /* closeWait */ )
@@ -843,8 +850,14 @@ tcpTable_load(netsnmp_cache *cache, void
nnew = SNMP_MALLOC_TYPEDEF(netsnmp_inpcb);
if (!nnew)
break;
- NETSNMP_KLOOKUP(entry, (char *)&(nnew->pcb), sizeof(struct inpcb));
- NETSNMP_KLOOKUP(nnew->pcb.inp_ppcb, (char *)&tcpcb, sizeof(struct tcpcb));
+ if (!NETSNMP_KLOOKUP(entry, (char *)&(nnew->pcb), sizeof(struct inpcb))) {
+ DEBUGMSGTL(("mibII/tcpTable:tcpTable_load", "klookup failed\n"));
+ break;
+ }
+ if (!NETSNMP_KLOOKUP(nnew->pcb.inp_ppcb, (char *)&tcpcb, sizeof(struct tcpcb))) {
+ DEBUGMSGTL(("mibII/tcpTable:tcpTable_load", "klookup failed\n"));
+ break;
+ }
nnew->state = StateMap[tcpcb.t_state];
if (nnew->state == 5 /* established */ ||
nnew->state == 8 /* closeWait */ )
Index: agent/mibgroup/mibII/udpTable.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/mibII/udpTable.c,v
retrieving revision 5.27
diff -u -p -r5.27 udpTable.c
--- agent/mibgroup/mibII/udpTable.c 14 Oct 2006 21:28:37 -0000 5.27
+++ agent/mibgroup/mibII/udpTable.c 5 Nov 2006 22:13:24 -0000
@@ -690,7 +690,10 @@ udpTable_load(netsnmp_cache *cache, void
if (!nnew)
break;
- NETSNMP_KLOOKUP(entry, (char *) nnew, sizeof(struct inpcb));
+ if (!NETSNMP_KLOOKUP(entry, (char *) nnew, sizeof(struct inpcb))) {
+ DEBUGMSGTL(("mibII/udpTable:udpTable_load", "klookup failed\n"));
+ break;
+ }
entry = nnew->inp_queue.cqe_next; /* Next kernel entry */
nnew->inp_queue.cqe_next = udp_head;
@@ -733,7 +736,10 @@ udpTable_load(netsnmp_cache *cache, void
if (!nnew)
break;
- NETSNMP_KLOOKUP(entry, (char *) nnew, sizeof(struct inpcb));
+ if (!NETSNMP_KLOOKUP(entry, (char *) nnew, sizeof(struct inpcb))) {
+ DEBUGMSGTL(("mibII/udpTable:udpTable_load", "klookup failed\n"));
+ break;
+ }
entry = nnew->INP_NEXT_SYMBOL; /* Next kernel entry */
nnew->INP_NEXT_SYMBOL = udp_head;
Index: agent/mibgroup/mibII/var_route.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/mibII/var_route.c,v
retrieving revision 5.25
diff -u -p -r5.25 var_route.c
--- agent/mibgroup/mibII/var_route.c 14 Oct 2006 21:28:37 -0000 5.25
+++ agent/mibgroup/mibII/var_route.c 5 Nov 2006 22:13:24 -0000
@@ -404,9 +404,16 @@ static union {
struct sockaddr_in *
klgetsa(struct sockaddr_in *dst)
{
- NETSNMP_KLOOKUP(dst, (char *) &klgetsatmp.sin, sizeof klgetsatmp.sin);
- if (klgetsatmp.sin.sin_len > sizeof(klgetsatmp.sin))
- NETSNMP_KLOOKUP(dst, (char *) &klgetsatmp.sin, klgetsatmp.sin.sin_len);
+ if (!NETSNMP_KLOOKUP(dst, (char *) &klgetsatmp.sin, sizeof klgetsatmp.sin)) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return NULL;
+ }
+ if (klgetsatmp.sin.sin_len > sizeof(klgetsatmp.sin)) {
+ if (!NETSNMP_KLOOKUP(dst, (char *) &klgetsatmp.sin, klgetsatmp.sin.sin_len)) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return NULL;
+ }
+ }
return (&klgetsatmp.sin);
}
#endif
@@ -652,10 +659,16 @@ var_ipRouteEntry(struct variable * vp,
long_return = 0; /* Default route */
else {
#ifndef linux
- NETSNMP_KLOOKUP(rthead[RtIndex]->rt_ifp,
- (char *) &rt_ifnet, sizeof(rt_ifnet));
- NETSNMP_KLOOKUP(rt_ifnet.if_addrlist,
- (char *) &rt_ifnetaddr, sizeof(rt_ifnetaddr));
+ if (!NETSNMP_KLOOKUP(rthead[RtIndex]->rt_ifp,
+ (char *) &rt_ifnet, sizeof(rt_ifnet))) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return NULL;
+ }
+ if (!NETSNMP_KLOOKUP(rt_ifnet.if_addrlist,
+ (char *) &rt_ifnetaddr, sizeof(rt_ifnetaddr))) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return NULL;
+ }
long_return = rt_ifnetaddr.ia_subnetmask;
#else /* linux */
@@ -882,19 +895,31 @@ load_rtentries(struct radix_node *pt)
/*
* get the route
*/
- NETSNMP_KLOOKUP(pt, (char *) &rt, sizeof(RTENTRY));
+ if (!NETSNMP_KLOOKUP(pt, (char *) &rt, sizeof(RTENTRY))) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return;
+ }
if (rt.rt_ifp != 0) {
- NETSNMP_KLOOKUP(rt.rt_ifp, (char *) &ifnet, sizeof(ifnet));
+ if (!NETSNMP_KLOOKUP(rt.rt_ifp, (char *) &ifnet, sizeof(ifnet))) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return;
+ }
#if STRUCT_IFNET_HAS_IF_XNAME
#if defined(netbsd1) || defined(openbsd2)
strncpy(name, ifnet.if_xname, sizeof name);
#else
- NETSNMP_KLOOKUP(ifnet.if_xname, name, sizeof name);
+ if (!NETSNMP_KLOOKUP(ifnet.if_xname, name, sizeof name)) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return;
+ }
#endif
name[sizeof(name) - 1] = '\0';
#else
- NETSNMP_KLOOKUP(ifnet.if_name, name, sizeof name);
+ if (!NETSNMP_KLOOKUP(ifnet.if_name, name, sizeof name)) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return;
+ }
name[sizeof(name) - 1] = '\0';
cp = (char *) strchr(name, '\0');
string_append_int(cp, ifnet.if_unit);
@@ -1062,13 +1087,22 @@ Route_Scan_Reload(void)
/*
* Dig the route out of the kernel...
*/
- NETSNMP_KLOOKUP(m, (char *) &mb, sizeof(mb));
+ if (!NETSNMP_KLOOKUP(m, (char *) &mb, sizeof(mb))) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return;
+ }
m = mb.rt_next;
rt = &mb;
if (rt->rt_ifp != 0) {
- NETSNMP_KLOOKUP(rt->rt_ifp, (char *) &ifnet, sizeof(ifnet));
- NETSNMP_KLOOKUP(ifnet.if_name, name, 16);
+ if (!NETSNMP_KLOOKUP(rt->rt_ifp, (char *) &ifnet, sizeof(ifnet))) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return;
+ }
+ if (!NETSNMP_KLOOKUP(ifnet.if_name, name, 16)) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return;
+ }
name[15] = '\0';
cp = (char *) strchr(name, '\0');
string_append_int(cp, ifnet.if_unit);
@@ -1179,14 +1213,23 @@ Route_Scan_Reload(void)
/*
* Dig the route out of the kernel...
*/
- NETSNMP_KLOOKUP(m, (char *) &mb, sizeof(mb));
+ if (!NETSNMP_KLOOKUP(m, (char *) &mb, sizeof(mb))) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return;
+ }
m = mb.m_next;
rt = mtod(&mb, RTENTRY *);
if (rt->rt_ifp != 0) {
- NETSNMP_KLOOKUP(rt->rt_ifp, (char *) &ifnet, sizeof(ifnet));
- NETSNMP_KLOOKUP(ifnet.if_name, name, 16);
+ if (!NETSNMP_KLOOKUP(rt->rt_ifp, (char *) &ifnet, sizeof(ifnet))) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return;
+ }
+ if (!NETSNMP_KLOOKUP(ifnet.if_name, name, 16)) {
+ DEBUGMSGTL(("mibII/var_route", "klookup failed\n"));
+ return;
+ }
name[15] = '\0';
cp = (char *) strchr(name, '\0');
string_append_int(cp, ifnet.if_unit);
-------------------------------------------------------------------------
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