From 10a00758a76956be734353caf0a88205de51009f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 20 Apr 2018 10:18:47 -0400 Subject: [PATCH] pbrd: Fix a couple SA issues 1) addr will never be non-null because of the way we build the cli at this point in time, but the SA system does not understand this, add a bread crumb for it. 2) Fix a possible memory leak of the pbr_ifp 3) Fix possible integer overflow when bit shifting. Signed-off-by: Donald Sharp --- pbrd/pbr_vty.c | 5 +++++ pbrd/pbr_zebra.c | 13 +++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 475ad86b58..03f2104835 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -227,6 +227,11 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd, memset(&nhop, 0, sizeof(nhop)); nhop.vrf_id = vrf->vrf_id; + /* + * Make SA happy. CLIPPY is not going to give us a NULL + * addr. + */ + assert(addr); if (addr->sa.sa_family == AF_INET) { nhop.gate.ipv4.s_addr = addr->sin.sin_addr.s_addr; if (intf) { diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c index 4e5b5f3dde..bc7dd20832 100644 --- a/pbrd/pbr_zebra.c +++ b/pbrd/pbr_zebra.c @@ -60,7 +60,8 @@ struct pbr_interface *pbr_if_new(struct interface *ifp) return 0; } - return (pbr_ifp); + ifp->info = pbr_ifp; + return pbr_ifp; } /* Inteface addition message from zebra. */ @@ -74,12 +75,8 @@ static int interface_add(int command, struct zclient *zclient, if (!ifp) return 0; - if (!ifp->info) { - struct pbr_interface *pbr_ifp; - - pbr_ifp = pbr_if_new(ifp); - ifp->info = pbr_ifp; - } + if (!ifp->info) + pbr_if_new(ifp); return 0; } @@ -494,7 +491,7 @@ void pbr_send_pbr_map(struct pbr_map_sequence *pbrms, { struct pbr_map *pbrm = pbrms->parent; struct stream *s; - uint64_t is_installed = 1 << pmi->install_bit; + uint64_t is_installed = (uint64_t)1 << pmi->install_bit; is_installed &= pbrms->installed; -- 2.39.5