From ea84953d8b8bab5372086e1582c15094136266eb Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Mon, 2 Nov 2020 15:00:00 +0100 Subject: [PATCH 1/2] uhcp: fix line length --- sys/net/application_layer/uhcp/uhcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/net/application_layer/uhcp/uhcp.c b/sys/net/application_layer/uhcp/uhcp.c index 3c5b554b49..b84a961a7f 100644 --- a/sys/net/application_layer/uhcp/uhcp.c +++ b/sys/net/application_layer/uhcp/uhcp.c @@ -104,7 +104,8 @@ void uhcp_handle_push(uhcp_push_t *req, uint8_t *src, uint16_t port, uhcp_iface_ inet_ntop(AF_INET6, prefix, prefix_str, INET6_ADDRSTRLEN); - LOG_INFO("uhcp: push from %s:%u prefix=%s/%u\n", addr_str, (unsigned)port, prefix_str, req->prefix_len); + LOG_INFO("uhcp: push from %s:%u prefix=%s/%u\n", addr_str, (unsigned)port, + prefix_str, req->prefix_len); uhcp_handle_prefix(prefix, req->prefix_len, 0xFFFF, src, iface); } #endif From 2d549688813d6cce415b322b6c25fa864244782c Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Mon, 2 Nov 2020 15:01:03 +0100 Subject: [PATCH 2/2] uhcp: fix handling of pushed prefix --- sys/net/application_layer/uhcp/uhcp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/net/application_layer/uhcp/uhcp.c b/sys/net/application_layer/uhcp/uhcp.c index b84a961a7f..1a8d239bd7 100644 --- a/sys/net/application_layer/uhcp/uhcp.c +++ b/sys/net/application_layer/uhcp/uhcp.c @@ -97,9 +97,12 @@ void uhcp_handle_push(uhcp_push_t *req, uint8_t *src, uint16_t port, uhcp_iface_ char addr_str[INET6_ADDRSTRLEN]; char prefix_str[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, src, addr_str, INET6_ADDRSTRLEN); - uint8_t prefix[16]; + uint8_t prefix[IN6ADDRSZ] = { 0 }; + if (req->prefix_len == 0) { + LOG_ERROR("uhcp_handle_push(): prefix length 0\n"); + return; + } size_t prefix_bytes = (req->prefix_len + 7)>>3; - memset(prefix + 16 - prefix_bytes, '\0', 16 - prefix_bytes); memcpy(prefix, req->prefix, prefix_bytes); inet_ntop(AF_INET6, prefix, prefix_str, INET6_ADDRSTRLEN);