fixed bug #36840 snmp_send_trap() NULL de-reference if traps configured but no interfaces available

This commit is contained in:
goldsimon 2012-08-13 21:38:30 +02:00
parent 556a2126b5
commit b82bca7c99
2 changed files with 48 additions and 40 deletions

View File

@ -80,6 +80,10 @@ HISTORY
++ Bugfixes: ++ Bugfixes:
2012-08-13: Simon Goldschmidt
* msg_out.c: fixed bug #36840 snmp_send_trap() NULL de-reference if traps
configured but no interfaces available
2012-08-13: Simon Goldschmidt 2012-08-13: Simon Goldschmidt
* dns.c: fixed bug #36899 DNS TTL 0 is cached for a long time * dns.c: fixed bug #36899 DNS TTL 0 is cached for a long time

View File

@ -217,6 +217,7 @@ snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap)
ip_addr_t dst_ip; ip_addr_t dst_ip;
struct pbuf *p; struct pbuf *p;
u16_t i,tot_len; u16_t i,tot_len;
err_t err = ERR_OK;
for (i=0, td = &trap_dst[0]; i<SNMP_TRAP_DESTINATIONS; i++, td++) for (i=0, td = &trap_dst[0]; i<SNMP_TRAP_DESTINATIONS; i++, td++)
{ {
@ -226,6 +227,7 @@ snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap)
ip_addr_copy(trap_msg.dip, td->dip); ip_addr_copy(trap_msg.dip, td->dip);
/* lookup current source address for this dst */ /* lookup current source address for this dst */
dst_if = ip_route(&td->dip); dst_if = ip_route(&td->dip);
if (dst_if != NULL) {
ip_addr_copy(dst_ip, dst_if->ip_addr); ip_addr_copy(dst_ip, dst_if->ip_addr);
/* @todo: what about IPv6? */ /* @todo: what about IPv6? */
trap_msg.sip_raw[0] = ip4_addr1(&dst_ip); trap_msg.sip_raw[0] = ip4_addr1(&dst_ip);
@ -267,14 +269,16 @@ snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap)
udp_sendto(trap_msg.pcb, p, &trap_msg.dip, SNMP_TRAP_PORT); udp_sendto(trap_msg.pcb, p, &trap_msg.dip, SNMP_TRAP_PORT);
pbuf_free(p); pbuf_free(p);
} else {
err = ERR_MEM;
} }
else } else {
{ /* routing error */
return ERR_MEM; err = ERR_RTE;
} }
} }
} }
return ERR_OK; return err;
} }
void void