Skip to content

Commit efd99e6

Browse files
committed
tests: net: ip-addr: Avoid possible null pointer dereference
Check return value of net_if_ipv6_get_ll() before accessing it. Coverity-CID: 199437 Fixes #17201 Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 08d10e1 commit efd99e6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tests/net/ip-addr/src/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ static void test_ipv6_addresses(void)
291291
ifaddr2->addr_state = NET_ADDR_PREFERRED;
292292

293293
tmp = net_if_ipv6_get_ll(net_if_get_default(), NET_ADDR_PREFERRED);
294-
zassert_false(memcmp(tmp, &addr6.s6_addr, sizeof(struct in6_addr)),
294+
zassert_false(tmp && memcmp(tmp, &addr6.s6_addr,
295+
sizeof(struct in6_addr)),
295296
"IPv6 ll address fetch failed");
296297

297298
ifaddr2->addr_state = NET_ADDR_DEPRECATED;

tests/net/ip-addr/testcase.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
common:
22
depends_on: netif
3-
platform_whitelist: native_posix qemu_x86 qemu_cortex_m3
3+
tags: net ip-addr
44
tests:
55
net.ip-addr:
66
min_ram: 16
7-
tags: net ip-addr

0 commit comments

Comments
 (0)