2007-11-19 07:50:57 +00:00
|
|
|
386611: snmpd segfaults on xen network interfaces
|
|
|
|
Source: http://sourceforge.net/tracker/index.php?func=detail&aid=1794532&group_id=12694&atid=112694
|
|
|
|
Reviewed-By: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
|
|
|
|
Index: agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c
|
|
|
|
===================================================================
|
2008-07-25 11:03:32 +00:00
|
|
|
diff -up net-snmp-5.4.1/agent/mibgroup/ip-mib/data_access/ipaddress_common.c.backup_patch_16 net-snmp-5.4.1/agent/mibgroup/ip-mib/data_access/ipaddress_common.c
|
|
|
|
--- net-snmp-5.4.1/agent/mibgroup/ip-mib/data_access/ipaddress_common.c.backup_patch_16 2007-07-17 01:59:44.000000000 +0200
|
|
|
|
+++ net-snmp-5.4.1/agent/mibgroup/ip-mib/data_access/ipaddress_common.c 2008-07-25 12:53:57.000000000 +0200
|
|
|
|
@@ -411,6 +411,7 @@ static int _access_ipaddress_entry_compa
|
|
|
|
{
|
|
|
|
const netsnmp_ipaddress_entry *lh = (const netsnmp_ipaddress_entry *)lhs;
|
|
|
|
const netsnmp_ipaddress_entry *rh = (const netsnmp_ipaddress_entry *)rhs;
|
|
|
|
+ int rc;
|
|
|
|
|
|
|
|
netsnmp_assert(NULL != lhs);
|
|
|
|
netsnmp_assert(NULL != rhs);
|
|
|
|
@@ -426,5 +427,17 @@ static int _access_ipaddress_entry_compa
|
|
|
|
/*
|
|
|
|
* length equal, compare address
|
|
|
|
*/
|
|
|
|
- return memcmp(lh->ia_address, rh->ia_address, lh->ia_address_len);
|
|
|
|
+ rc = memcmp(lh->ia_address, rh->ia_address, lh->ia_address_len);
|
|
|
|
+ if (rc)
|
|
|
|
+ return rc;
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * address same, compare ifIndex
|
|
|
|
+ */
|
|
|
|
+ if (lh->if_index < rh->if_index)
|
|
|
|
+ return -1;
|
|
|
|
+ else if (lh->if_index > rh->if_index)
|
|
|
|
+ return 1;
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
}
|
|
|
|
diff -up net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c.backup_patch_16 net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c
|
|
|
|
--- net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c.backup_patch_16 2006-12-06 16:10:40.000000000 +0100
|
|
|
|
+++ net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c 2008-07-25 12:53:57.000000000 +0200
|
|
|
|
@@ -348,10 +348,18 @@ ipAddressAddrType_map(u_long * mib_ipAdd
|
2007-11-19 07:50:57 +00:00
|
|
|
*mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
+ case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4Z:
|
|
|
|
+ *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV4Z;
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6:
|
|
|
|
*mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV6;
|
|
|
|
break;
|
|
|
|
|
|
|
|
+ case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6Z:
|
|
|
|
+ *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV6Z;
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
default:
|
|
|
|
snmp_log(LOG_ERR, "couldn't map value %ld for ipAddressAddrType\n",
|
|
|
|
raw_ipAddressAddrType_val);
|
2008-07-25 11:03:32 +00:00
|
|
|
@@ -382,8 +390,11 @@ int
|
2007-11-19 07:50:57 +00:00
|
|
|
ipAddressTable_indexes_set_tbl_idx(ipAddressTable_mib_index * tbl_idx,
|
|
|
|
u_long ipAddressAddrType_val,
|
|
|
|
char *ipAddressAddr_val_ptr,
|
|
|
|
- size_t ipAddressAddr_val_ptr_len)
|
|
|
|
+ size_t ipAddressAddr_val_ptr_len,
|
|
|
|
+ u_long ipAddressAddr_ifIndex)
|
|
|
|
{
|
|
|
|
+ uint32_t zone = htonl(ipAddressAddr_ifIndex);
|
|
|
|
+
|
|
|
|
DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_indexes_set_tbl_idx", "called\n"));
|
|
|
|
|
|
|
|
/*
|
2008-07-25 11:03:32 +00:00
|
|
|
@@ -409,6 +420,11 @@ ipAddressTable_indexes_set_tbl_idx(ipAdd
|
2007-11-19 07:50:57 +00:00
|
|
|
memcpy(tbl_idx->ipAddressAddr, ipAddressAddr_val_ptr,
|
|
|
|
ipAddressAddr_val_ptr_len * sizeof(ipAddressAddr_val_ptr[0]));
|
|
|
|
|
|
|
|
+ /** zone */
|
|
|
|
+ tbl_idx->ipAddressAddr_len += sizeof(zone);
|
|
|
|
+ memcpy(&tbl_idx->ipAddressAddr[ipAddressAddr_val_ptr_len *
|
|
|
|
+ sizeof(ipAddressAddr_val_ptr[0])],
|
|
|
|
+ &zone, sizeof(zone));
|
|
|
|
|
|
|
|
return MFD_SUCCESS;
|
|
|
|
} /* ipAddressTable_indexes_set_tbl_idx */
|
2008-07-25 11:03:32 +00:00
|
|
|
@@ -430,7 +446,8 @@ int
|
2007-11-19 07:50:57 +00:00
|
|
|
ipAddressTable_indexes_set(ipAddressTable_rowreq_ctx * rowreq_ctx,
|
|
|
|
u_long ipAddressAddrType_val,
|
|
|
|
char *ipAddressAddr_val_ptr,
|
|
|
|
- size_t ipAddressAddr_val_ptr_len)
|
|
|
|
+ size_t ipAddressAddr_val_ptr_len,
|
|
|
|
+ u_long ipAddressAddr_ifIndex)
|
|
|
|
{
|
|
|
|
DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_indexes_set",
|
|
|
|
"called\n"));
|
2008-07-25 11:03:32 +00:00
|
|
|
@@ -439,7 +456,8 @@ ipAddressTable_indexes_set(ipAddressTabl
|
2007-11-19 07:50:57 +00:00
|
|
|
ipAddressTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx,
|
|
|
|
ipAddressAddrType_val,
|
|
|
|
ipAddressAddr_val_ptr,
|
|
|
|
- ipAddressAddr_val_ptr_len))
|
|
|
|
+ ipAddressAddr_val_ptr_len,
|
|
|
|
+ ipAddressAddr_ifIndex))
|
|
|
|
return MFD_ERROR;
|
|
|
|
|
|
|
|
/*
|
2008-07-25 11:03:32 +00:00
|
|
|
diff -up net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h.backup_patch_16 net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h
|
|
|
|
--- net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h.backup_patch_16 2005-12-01 18:00:57.000000000 +0100
|
|
|
|
+++ net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h 2008-07-25 12:53:57.000000000 +0200
|
|
|
|
@@ -106,7 +106,9 @@ extern "C" {
|
2007-11-19 07:50:57 +00:00
|
|
|
* simplistic map of address length to type
|
|
|
|
*/
|
|
|
|
#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4 4
|
|
|
|
+#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4Z 5
|
|
|
|
#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6 16
|
|
|
|
+#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6Z 17
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************
|
2008-07-25 11:03:32 +00:00
|
|
|
diff -up net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c.backup_patch_16 net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c
|
|
|
|
--- net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c.backup_patch_16 2007-05-17 23:53:28.000000000 +0200
|
|
|
|
+++ net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c 2008-07-25 12:53:57.000000000 +0200
|
|
|
|
@@ -258,9 +258,10 @@ _add_new_entry(netsnmp_ipaddress_entry *
|
|
|
|
if ((NULL != rowreq_ctx) &&
|
|
|
|
(MFD_SUCCESS ==
|
|
|
|
ipAddressTable_indexes_set(rowreq_ctx,
|
|
|
|
- ipaddress_entry->ia_address_len,
|
|
|
|
+ ipaddress_entry->ia_address_len + 1,
|
|
|
|
ipaddress_entry->ia_address,
|
|
|
|
- ipaddress_entry->ia_address_len))) {
|
|
|
|
+ ipaddress_entry->ia_address_len,
|
|
|
|
+ ipaddress_entry->if_index))) {
|
|
|
|
if (CONTAINER_INSERT(container, rowreq_ctx) < 0) {
|
|
|
|
DEBUGMSGTL (("ipAddressTable:access","container insert failed for new entry\n"));
|
|
|
|
ipAddressTable_release_rowreq_ctx(rowreq_ctx);
|
|
|
|
diff -up net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h.backup_patch_16 net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h
|
|
|
|
--- net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h.backup_patch_16 2006-01-25 17:28:12.000000000 +0100
|
|
|
|
+++ net-snmp-5.4.1/agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h 2008-07-25 12:53:57.000000000 +0200
|
|
|
|
@@ -273,14 +273,16 @@ config_require(ip-mib/ipAddressTable/ipA
|
2007-11-19 07:50:57 +00:00
|
|
|
u_long ipAddressAddrType_val,
|
|
|
|
char *ipAddressAddr_val_ptr,
|
|
|
|
size_t
|
|
|
|
- ipAddressAddr_val_ptr_len);
|
|
|
|
+ ipAddressAddr_val_ptr_len,
|
|
|
|
+ u_long ipAddressAddr_ifIndex);
|
|
|
|
int ipAddressTable_indexes_set(ipAddressTable_rowreq_ctx *
|
|
|
|
rowreq_ctx,
|
|
|
|
u_long
|
|
|
|
ipAddressAddrType_val,
|
|
|
|
char *ipAddressAddr_val_ptr,
|
|
|
|
size_t
|
|
|
|
- ipAddressAddr_val_ptr_len);
|
|
|
|
+ ipAddressAddr_val_ptr_len,
|
|
|
|
+ u_long ipAddressAddr_ifIndex);
|
|
|
|
|
|
|
|
|
|
|
|
|