From 365bfd81af50c4069b4eb5ba945eaaa0c4f879b2 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Sat, 8 Nov 2014 20:06:03 +0100 Subject: [PATCH] IPv6: allow complete in ipv6_addr_init_prefix If the specified prefix is a full IPv6 address, no bits remain. Fixes a possible buffer overrun. --- sys/net/network_layer/sixlowpan/ip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/net/network_layer/sixlowpan/ip.c b/sys/net/network_layer/sixlowpan/ip.c index 060b19462c..afb7920581 100644 --- a/sys/net/network_layer/sixlowpan/ip.c +++ b/sys/net/network_layer/sixlowpan/ip.c @@ -658,7 +658,9 @@ void ipv6_addr_init_prefix(ipv6_addr_t *out, const ipv6_addr_t *prefix, } memcpy(out, prefix, bytes); - out->uint8[bytes] = prefix->uint8[bytes] & mask; + if (bytes < 16) { + out->uint8[bytes] = prefix->uint8[bytes] & mask; + } memset(&(out[bytes + 1]), 0, 15 - bytes); }