summaryrefslogtreecommitdiffstats
path: root/pbrd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2021-01-17 13:48:20 +0100
committerDonald Sharp <sharpd@nvidia.com>2021-01-18 15:06:49 +0100
commit920bb6f76af216d73991bfa21726baa5d31051d3 (patch)
treef1813f8eafaeffc6dc9394427cdd851ab1f18335 /pbrd
parentbgpd: attr is already derefed cannot be null here (diff)
downloadfrr-920bb6f76af216d73991bfa21726baa5d31051d3.tar.xz
frr-920bb6f76af216d73991bfa21726baa5d31051d3.zip
pbrd: Prevent possible NULL use
the pnhi data structure can receive either a interface or a nhr data structure. Ensure that we don't crash. CID -> 1500586 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'pbrd')
-rw-r--r--pbrd/pbr_nht.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c
index dbe5de724..f99971ab7 100644
--- a/pbrd/pbr_nht.c
+++ b/pbrd/pbr_nht.c
@@ -770,18 +770,20 @@ pbr_nht_individual_nexthop_gw_update(struct pbr_nexthop_cache *pnhc,
goto done;
}
- switch (pnhi->nhr->prefix.family) {
- case AF_INET:
- if (pnhc->nexthop.gate.ipv4.s_addr
- != pnhi->nhr->prefix.u.prefix4.s_addr)
- goto done; /* Unrelated change */
- break;
- case AF_INET6:
- if (memcmp(&pnhc->nexthop.gate.ipv6,
- &pnhi->nhr->prefix.u.prefix6, 16)
- != 0)
- goto done; /* Unrelated change */
- break;
+ if (pnhi->nhr) {
+ switch (pnhi->nhr->prefix.family) {
+ case AF_INET:
+ if (pnhc->nexthop.gate.ipv4.s_addr
+ != pnhi->nhr->prefix.u.prefix4.s_addr)
+ goto done; /* Unrelated change */
+ break;
+ case AF_INET6:
+ if (memcmp(&pnhc->nexthop.gate.ipv6,
+ &pnhi->nhr->prefix.u.prefix6, 16)
+ != 0)
+ goto done; /* Unrelated change */
+ break;
+ }
}
pnhi->nhr_matched = true;