Skip to content

Commit 42f502d

Browse files
tiwaiJiri Kosina
authored andcommitted
HID: hid-picolcd_fb: 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: Jiri Kosina <[email protected]>
1 parent 4eb1b01 commit 42f502d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/hid/hid-picolcd_fb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,9 @@ static ssize_t picolcd_fb_update_rate_show(struct device *dev,
459459
if (ret >= PAGE_SIZE)
460460
break;
461461
else if (i == fb_update_rate)
462-
ret += snprintf(buf+ret, PAGE_SIZE-ret, "[%u] ", i);
462+
ret += scnprintf(buf+ret, PAGE_SIZE-ret, "[%u] ", i);
463463
else
464-
ret += snprintf(buf+ret, PAGE_SIZE-ret, "%u ", i);
464+
ret += scnprintf(buf+ret, PAGE_SIZE-ret, "%u ", i);
465465
if (ret > 0)
466466
buf[min(ret, (size_t)PAGE_SIZE)-1] = '\n';
467467
return ret;

0 commit comments

Comments
 (0)