From 3c04071d996f84f265776f068ff21dc48d895139 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Mon, 23 Jul 2018 18:33:53 -0400 Subject: [PATCH] zebra: Add check for nexthop loop to prevent hanging Bad nexthop messages from netlink were causing zebra to hang here. Added a check to verify the length of the nexthop so it doesn't keep trying to read. Signed-off-by: Stephen Worley --- zebra/rt_netlink.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index b346247d4b..ec84c4c622 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -581,6 +581,9 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id, route_entry_nexthop_ifindex_add( re, index, nh_vrf_id); + if (rtnh->rtnh_len == 0) + break; + len -= NLMSG_ALIGN(rtnh->rtnh_len); rtnh = RTNH_NEXT(rtnh); } @@ -701,6 +704,9 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h, oif[oif_count] = rtnh->rtnh_ifindex; oif_count++; + if (rtnh->rtnh_len == 0) + break; + len -= NLMSG_ALIGN(rtnh->rtnh_len); rtnh = RTNH_NEXT(rtnh); } -- 2.39.5