Commit 1009ccd
committed
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 <[email protected]>1 parent 5771a8c commit 1009ccd
1 file changed
+9
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| 569 | + | |
| 570 | + | |
569 | 571 | | |
570 | 572 | | |
571 | 573 | | |
| |||
811 | 813 | | |
812 | 814 | | |
813 | 815 | | |
814 | | - | |
| 816 | + | |
| 817 | + | |
815 | 818 | | |
816 | 819 | | |
817 | 820 | | |
| |||
834 | 837 | | |
835 | 838 | | |
836 | 839 | | |
837 | | - | |
| 840 | + | |
| 841 | + | |
838 | 842 | | |
839 | 843 | | |
840 | 844 | | |
| |||
903 | 907 | | |
904 | 908 | | |
905 | 909 | | |
906 | | - | |
| 910 | + | |
907 | 911 | | |
908 | 912 | | |
909 | 913 | | |
| |||
1116 | 1120 | | |
1117 | 1121 | | |
1118 | 1122 | | |
1119 | | - | |
| 1123 | + | |
| 1124 | + | |
1120 | 1125 | | |
1121 | 1126 | | |
1122 | 1127 | | |
| |||
0 commit comments