KSPP / linux

Linux kernel source tree (Kernel Self Protection Project)
https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project
Other
83 stars 5 forks source link

Address -Warray-bounds warnings in drivers/leds/trigger/ledtrig-netdev.c #332

Closed GustavoARSilva closed 9 months ago

GustavoARSilva commented 1 year ago

Found in x86 with allyesconfig (GCC 13):

drivers/leds/trigger/ledtrig-netdev.c: In function 'set_device_name':
drivers/leds/trigger/ledtrig-netdev.c:234:34: warning: array subscript 17 is above array bounds of 'char[16]' [-Warray-bounds=]
  234 |         trigger_data->device_name[size] = 0;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
drivers/leds/trigger/ledtrig-netdev.c:52:14: note: while referencing 'device_name'
   52 |         char device_name[IFNAMSIZ];
      |              ^~~~~~~~~~~
drivers/leds/trigger/ledtrig-netdev.c:234:34: warning: array subscript 17 is above array bounds of 'char[16]' [-Warray-bounds=]
  234 |         trigger_data->device_name[size] = 0;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
drivers/leds/trigger/ledtrig-netdev.c:52:14: note: while referencing 'device_name'
   52 |         char device_name[IFNAMSIZ];
      |              ^~~~~~~~~~~

drivers/leds/trigger/ledtrig-netdev.c:

233         memcpy(trigger_data->device_name, name, size);
@234         trigger_data->device_name[size] = 0;
kees commented 9 months ago

Fixed in commit 259e33cbb1712a7dd844fc9757661cc47cb0e39b.