1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 09:33:50 +01:00

ipv6_addr: provide fix for off-by-x error

This commit is contained in:
Martine Lenders 2017-04-19 13:51:00 +02:00
parent 7f778988c3
commit eef90c06fb

View File

@ -96,7 +96,7 @@ ipv6_addr_t *ipv6_addr_from_str(ipv6_addr_t *result, const char *addr)
continue;
}
if (i > sizeof(ipv6_addr_t)) {
if ((i + sizeof(uint16_t)) > sizeof(ipv6_addr_t)) {
return NULL;
}
@ -108,7 +108,7 @@ ipv6_addr_t *ipv6_addr_from_str(ipv6_addr_t *result, const char *addr)
}
#ifdef MODULE_IPV4_ADDR
if (ch == '.' && (i <= sizeof(ipv6_addr_t)) &&
if (ch == '.' && ((i + sizeof(ipv4_addr_t)) <= sizeof(ipv6_addr_t)) &&
ipv4_addr_from_str((ipv4_addr_t *)(&(result->u8[i])),
curtok) != NULL) {
i += sizeof(ipv4_addr_t);