Skip to content

Commit

Permalink
uhcp: fix handling of pushed prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Nov 24, 2020
1 parent ea84953 commit 2d54968
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sys/net/application_layer/uhcp/uhcp.c
Expand Up @@ -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);
Expand Down

0 comments on commit 2d54968

Please sign in to comment.