mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
uhcp: check maximum for prefix length
This commit is contained in:
parent
1477a340fe
commit
44a94dd91e
@ -98,8 +98,9 @@ void uhcp_handle_push(uhcp_push_t *req, uint8_t *src, uint16_t port, uhcp_iface_
|
|||||||
char prefix_str[INET6_ADDRSTRLEN];
|
char prefix_str[INET6_ADDRSTRLEN];
|
||||||
inet_ntop(AF_INET6, src, addr_str, INET6_ADDRSTRLEN);
|
inet_ntop(AF_INET6, src, addr_str, INET6_ADDRSTRLEN);
|
||||||
uint8_t prefix[IN6ADDRSZ] = { 0 };
|
uint8_t prefix[IN6ADDRSZ] = { 0 };
|
||||||
if (req->prefix_len == 0) {
|
/* prefix_len can't be 0 or greater then IN6ADDRSZ * 8 (== 128) */
|
||||||
LOG_ERROR("uhcp_handle_push(): prefix length 0\n");
|
if ((req->prefix_len == 0) || (req->prefix_len > (IN6ADDRSZ << 3))) {
|
||||||
|
LOG_ERROR("uhcp_handle_push(): invalid prefix length\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t prefix_bytes = (req->prefix_len + 7)>>3;
|
size_t prefix_bytes = (req->prefix_len + 7)>>3;
|
||||||
|
Loading…
Reference in New Issue
Block a user