Skip to content

Commit e44ed8d

Browse files
jukkarkartben
authored andcommitted
net: ipv6: Make sure we do not access link address past array length
It is possible to manually set link address length past 6 at runtime and trying to generate IPv6 IID address that way. This should fail as we could read two bytes past the address buffer. There is no issues in the copying as the target buffer has plenty of space. Coverity-CID: 516232 Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
1 parent ec8632d commit e44ed8d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

subsys/net/ip/ipv6.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,12 @@ int net_ipv6_addr_generate_iid(struct net_if *iface,
10301030

10311031
break;
10321032
case 8:
1033+
if (sizeof(lladdr->addr) < 8) {
1034+
NET_ERR("Invalid link layer address length %zu, expecting 8",
1035+
sizeof(lladdr->addr));
1036+
return -EINVAL;
1037+
}
1038+
10331039
memcpy(&tmp_addr.s6_addr[8], lladdr->addr, lladdr->len);
10341040
tmp_addr.s6_addr[8] ^= 0x02;
10351041
break;

0 commit comments

Comments
 (0)