Skip to content

Commit d108b13

Browse files
tiwaigregkh
authored andcommitted
misc: mic: 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 <tiwai@suse.de> Link: https://lore.kernel.org/r/20200311074916.8783-1-tiwai@suse.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f276d3e commit d108b13

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/misc/mic/host/mic_x100.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,10 @@ mic_x100_load_command_line(struct mic_device *mdev, const struct firmware *fw)
350350
if (!buf)
351351
return -ENOMEM;
352352

353-
len += snprintf(buf, CMDLINE_SIZE - len,
353+
len += scnprintf(buf, CMDLINE_SIZE - len,
354354
" mem=%dM", boot_mem);
355355
if (mdev->cosm_dev->cmdline)
356-
snprintf(buf + len, CMDLINE_SIZE - len, " %s",
356+
scnprintf(buf + len, CMDLINE_SIZE - len, " %s",
357357
mdev->cosm_dev->cmdline);
358358
memcpy_toio(cmd_line_va, buf, strlen(buf) + 1);
359359
kfree(buf);

0 commit comments

Comments
 (0)