From d63e98786e535c1454d33c3246c04a4b8f6bfc0b Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 8 Oct 2014 18:52:14 +0200 Subject: [PATCH] sixlowpan: fix ipv6_addr_init_prefix --- sys/net/network_layer/sixlowpan/ip.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/net/network_layer/sixlowpan/ip.c b/sys/net/network_layer/sixlowpan/ip.c index 2316ad6386..e7d2881711 100644 --- a/sys/net/network_layer/sixlowpan/ip.c +++ b/sys/net/network_layer/sixlowpan/ip.c @@ -651,16 +651,15 @@ void ipv6_addr_init_prefix(ipv6_addr_t *out, const ipv6_addr_t *prefix, uint8_t bytes = bits / 8, mask; if (bits % 8) { - mask = 0xff << (bits - (bytes * 8)); + mask = 0xff << (8 - (bits - (bytes * 8))); } else { mask = 0x00; } - bytes++; - memset(out, 0, 16); memcpy(out, prefix, bytes); out->uint8[bytes] = prefix->uint8[bytes] & mask; + memset(&(out[bytes + 1]), 0, 15 - bytes); } void ipv6_net_if_get_best_src_addr(ipv6_addr_t *src, const ipv6_addr_t *dest)