diff options
author | Steven Luong <sluong@cisco.com> | 2024-07-22 09:27:33 -0700 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2024-07-23 07:30:03 +0000 |
commit | 3ac2ac532497024725e19fdd6f33ecbfceb9ff05 (patch) | |
tree | 8f6b9e848322167c511823a772eb5dc0a48c540c /src/vnet/ip | |
parent | e99d266612b53163d460f3ceab96934b1d961ac8 (diff) |
ip: crash in ip4_sas_commonlen
ip4_sas_commonlen may be called with null a2 argument from
ip4_neighbor_advertise -> ip4_sas_by_sw_if_index.
If a1 or a2 is null, there is no common length, shortest mask
between a1 and a2, return 0 instead of crashing.
Type: fix
Change-Id: I307509ee7dedafac76d8877a1ef76ab8bbafef59
Signed-off-by: Steven Luong <sluong@cisco.com>
Diffstat (limited to 'src/vnet/ip')
-rw-r--r-- | src/vnet/ip/ip_sas.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/vnet/ip/ip_sas.c b/src/vnet/ip/ip_sas.c index 0fc261724f1..01f6c90baf8 100644 --- a/src/vnet/ip/ip_sas.c +++ b/src/vnet/ip/ip_sas.c @@ -54,6 +54,8 @@ ip6_sas_commonlen (const ip6_address_t *a1, const ip6_address_t *a2) static int ip4_sas_commonlen (const ip4_address_t *a1, const ip4_address_t *a2) { + if (!a1 || !a2) + return 0; u64 a = clib_net_to_host_u32 (a1->as_u32) ^ clib_net_to_host_u32 (a2->as_u32); if (a == 0) |