From 5e91cd47c9ddbf7a747a71c37b06193c1db416b1 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Wed, 28 Feb 2018 21:09:55 +0100 Subject: [PATCH] lowpan6.c: ensure netif->hwaddr_len == 8 (to not create invalid frames) --- src/netif/lowpan6.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/netif/lowpan6.c b/src/netif/lowpan6.c index 3a9a6785..d928bd8b 100644 --- a/src/netif/lowpan6.c +++ b/src/netif/lowpan6.c @@ -65,6 +65,10 @@ #include +#if NETIF_MAX_HWADDR_LEN < 8 +#error "6LoWPAN netif needs a 64-bit hwaddr" +#endif + /** This is a helper struct for reassembly of fragments * (IEEE 802.15.4 limits to 127 bytes) */ @@ -675,6 +679,7 @@ lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr) } else #endif /* LWIP_6LOWPAN_INFER_SHORT_ADDRESS */ { + LWIP_ASSERT("6LowPAN needs netif->hwaddr_len == 8", netif->hwaddr_len == 8); src.addr_len = netif->hwaddr_len; SMEMCPY(src.addr, netif->hwaddr, netif->hwaddr_len); } @@ -717,6 +722,7 @@ lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr) } /* Send out the packet using the returned hardware address. */ + LWIP_ASSERT("6LowPAN needs netif->hwaddr_len == 8", netif->hwaddr_len == 8); dest.addr_len = netif->hwaddr_len; SMEMCPY(dest.addr, hwaddr, netif->hwaddr_len); MIB2_STATS_NETIF_INC(netif, ifoutucastpkts);