diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-10-29 13:51:57 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-10-29 14:48:02 +0100 |
commit | d4395853e8af1e21c86d4d9227e702640af58ab1 (patch) | |
tree | cb79fd10ae079b5b2517049519d521817b485ada /eigrpd | |
parent | eigrpd: Fix crash in reply receive packet. (diff) | |
download | frr-d4395853e8af1e21c86d4d9227e702640af58ab1.tar.xz frr-d4395853e8af1e21c86d4d9227e702640af58ab1.zip |
eigrpd: When writing packet don't crash in some cases
When we are writing a packet if we have gotten ourselves
into a bad situation, note it and move on. Hopefully
dumping enough information so that we can find the offending
reason.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'eigrpd')
-rw-r--r-- | eigrpd/eigrp_packet.c | 15 | ||||
-rw-r--r-- | eigrpd/eigrp_query.c | 5 |
2 files changed, 15 insertions, 5 deletions
diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c index 83ff19472..5b54f8132 100644 --- a/eigrpd/eigrp_packet.c +++ b/eigrpd/eigrp_packet.c @@ -344,8 +344,18 @@ int eigrp_write(struct thread *thread) /* Get one packet from queue. */ ep = eigrp_fifo_next(ei->obuf); - assert(ep); - assert(ep->length >= EIGRP_HEADER_LEN); + if (!ep) { + zlog_err("%s: Interface %s no packet on queue?", + __PRETTY_FUNCTION__, ei->ifp->name); + goto out; + } + if (ep->length < EIGRP_HEADER_LEN) { + zlog_err("%s: Packet just has a header?", + __PRETTY_FUNCTION__); + eigrp_header_dump((struct eigrp_header *)ep->s->data); + eigrp_packet_delete(ei); + goto out; + } if (ep->dst.s_addr == htonl(EIGRP_MULTICAST_ADDRESS)) eigrp_if_ipmulticast(eigrp, ei->address, ei->ifp->ifindex); @@ -442,6 +452,7 @@ int eigrp_write(struct thread *thread) /* Now delete packet from queue. */ eigrp_packet_delete(ei); +out: if (eigrp_fifo_next(ei->obuf) == NULL) { ei->on_write_q = 0; list_delete_node(eigrp->oi_write_q, node); diff --git a/eigrpd/eigrp_query.c b/eigrpd/eigrp_query.c index 58f3d2b53..caa37870a 100644 --- a/eigrpd/eigrp_query.c +++ b/eigrpd/eigrp_query.c @@ -165,7 +165,7 @@ void eigrp_send_query(struct eigrp_interface *ei) struct listnode *node, *nnode, *node2, *nnode2; struct eigrp_neighbor *nbr; struct eigrp_prefix_entry *pe; - char has_tlv; + bool has_tlv = false; bool ep_saved = false; ep = eigrp_packet_new(ei->ifp->mtu, NULL); @@ -180,7 +180,6 @@ void eigrp_send_query(struct eigrp_interface *ei) length += eigrp_add_authTLV_MD5_to_stream(ep->s, ei); } - has_tlv = 0; for (ALL_LIST_ELEMENTS(ei->eigrp->topology_changes_internalIPV4, node, nnode, pe)) { if (!(pe->req_action & EIGRP_FSM_NEED_QUERY)) @@ -190,7 +189,7 @@ void eigrp_send_query(struct eigrp_interface *ei) for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) { if (nbr->state == EIGRP_NEIGHBOR_UP) { listnode_add(pe->rij, nbr); - has_tlv = 1; + has_tlv = true;; } } } |