]> git.baikalelectronics.ru Git - kernel.git/commit
hwmon: (applesmc) Avoid buffer overruns
authorGuenter Roeck <linux@roeck-us.net>
Wed, 12 Jul 2017 03:53:55 +0000 (20:53 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sat, 15 Jul 2017 23:38:56 +0000 (16:38 -0700)
commit25981e54f542a4ce58aa37dcf6629dd2fded005f
tree1550e7c64fa36ed378ae26a874d9a694027d4d5a
parent9238ecfbaaeffcf7977c2776af9c57c0a4a878ed
hwmon: (applesmc) Avoid buffer overruns

gcc 7.1 complains that the driver uses sprintf() and thus does not validate
the length of output buffers.

drivers/hwmon/applesmc.c: In function 'applesmc_show_fan_position':
drivers/hwmon/applesmc.c:82:21: warning:
'%d' directive writing between 1 and 5 bytes into a region of size 4

Fix the problem by using scnprintf() instead of sprintf() throughout the
driver. Also explicitly limit the number of supported fans to avoid actual
buffer overruns and thus invalid keys.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/applesmc.c