Skip to content

Commit 9027f61

Browse files
tiwaisre
authored andcommitted
power: twl4030: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing with scnprintf(). Signed-off-by: Takashi Iwai <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 583b53e commit 9027f61

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/power/supply/twl4030_charger.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,10 +726,10 @@ twl4030_bci_mode_show(struct device *dev,
726726

727727
for (i = 0; i < ARRAY_SIZE(modes); i++)
728728
if (mode == i)
729-
len += snprintf(buf+len, PAGE_SIZE-len,
729+
len += scnprintf(buf+len, PAGE_SIZE-len,
730730
"[%s] ", modes[i]);
731731
else
732-
len += snprintf(buf+len, PAGE_SIZE-len,
732+
len += scnprintf(buf+len, PAGE_SIZE-len,
733733
"%s ", modes[i]);
734734
buf[len-1] = '\n';
735735
return len;

0 commit comments

Comments
 (0)