mirror of
https://github.com/apache/nuttx.git
synced 2026-05-12 01:42:49 +08:00
6c4bd5c5ef
* net/netdev/netdev_ioctl.c: (netdev_ifr_ioctl): The ioctl SIOCSIFHWADDR sets the hardware address (e.g., Ethernet MAC, etc.) of a network interface. Radio devices may have different lengths of hardware addresses, such as NET_6LOWPAN_EADDRSIZE (8), NET_6LOWPAN_SADDRSIZE (2), or RADIO_MAX_ADDRLEN (8). Also, Kconfig CONFIG_PKTRADIO_ADDRLEN allows the user to set any arbitrary size. Note that while the sister ioctl SIOCGIFHWADDR "get hardware address" copies `dev->d_mac.radio.nv_addrlen` bytes, SIOCSIFHWADDR was copying NET_6LOWPAN_ADDRSIZE bytes unconditionally. Depending on which radio is used, this could be incorrect. Fixing it to use `dev->d_mac.radio.nv_addrlen` for SIOCSIFHWADDR as well. Also adding DEBUGASSERT to ensure this is within bounds of source and destination of the copy.