From e0b84ba1f6864ae8fea691c13d9d4b80b85960f2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 13 Nov 2017 14:30:17 -0500 Subject: [PATCH] bgpd, zebra: Ensure that passed flags is 0 for unregister event The flags passed in should be 0 for an unregister event. Ensure that we respect that. Signed-off-by: Donald Sharp --- bgpd/bgp_label.c | 7 ++++++- zebra/zserv.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c index 06c314de03..60250513b6 100644 --- a/bgpd/bgp_label.c +++ b/bgpd/bgp_label.c @@ -154,7 +154,12 @@ void bgp_reg_dereg_for_label(struct bgp_node *rn, struct bgp_info *ri, int reg) /* Set length and flags */ stream_putw_at(s, 0, stream_get_endp(s)); - stream_putw_at(s, flags_pos, flags); + + /* + * We only need to write new flags if this is a register + */ + if (reg) + stream_putw_at(s, flags_pos, flags); zclient_send_message(zclient); } diff --git a/zebra/zserv.c b/zebra/zserv.c index 5387c9c380..fdd20d65a1 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -907,6 +907,9 @@ static int zserv_fec_unregister(struct zserv *client, u_short length) while (l < length) { STREAM_GETW(s, flags); + if (flags != 0) + goto stream_failure; + memset(&p, 0, sizeof(p)); STREAM_GETW(s, p.family); if (p.family != AF_INET && p.family != AF_INET6) { -- 2.39.5