From 0f4c5f5b100de96d071b8f2abd63c4445941adf7 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sun, 23 Aug 2020 14:05:52 +0200 Subject: [PATCH] drivers/at86rf2xx: fix assert The assert is reversed. It must check if the config value does not exceed the maximum address length, not the other way round. previously this would lead to a crash when setting a short address: 2020-08-23 13:59:56,080 # ifconfig 7 set addr_short 2 2020-08-23 13:59:56,081 # 0xdcad 2020-08-23 13:59:56,083 # *** RIOT kernel panic: 2020-08-23 13:59:56,085 # FAILED ASSERTION. With this it works as expected 2020-08-23 14:05:07,988 # ifconfig 7 set addr_short 2 2020-08-23 14:05:07,992 # success: set (short) address on interface 7 to 2 --- drivers/at86rf2xx/at86rf2xx_netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/at86rf2xx/at86rf2xx_netdev.c b/drivers/at86rf2xx/at86rf2xx_netdev.c index 16303567bb..3c83a43947 100644 --- a/drivers/at86rf2xx/at86rf2xx_netdev.c +++ b/drivers/at86rf2xx/at86rf2xx_netdev.c @@ -498,12 +498,12 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len) switch (opt) { case NETOPT_ADDRESS: - assert(len >= sizeof(network_uint16_t)); + assert(len <= sizeof(network_uint16_t)); at86rf2xx_set_addr_short(dev, val); /* don't set res to set netdev_ieee802154_t::short_addr */ break; case NETOPT_ADDRESS_LONG: - assert(len >= sizeof(eui64_t)); + assert(len <= sizeof(eui64_t)); at86rf2xx_set_addr_long(dev, val); /* don't set res to set netdev_ieee802154_t::long_addr */ break;