Skip to content

Commit b450b30

Browse files
tiwaiIngo Molnar
authored andcommitted
efi/cper: 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: Ard Biesheuvel <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 8f3d9f3 commit b450b30

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/firmware/efi/cper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void cper_print_bits(const char *pfx, unsigned int bits,
101101
if (!len)
102102
len = snprintf(buf, sizeof(buf), "%s%s", pfx, str);
103103
else
104-
len += snprintf(buf+len, sizeof(buf)-len, ", %s", str);
104+
len += scnprintf(buf+len, sizeof(buf)-len, ", %s", str);
105105
}
106106
if (len)
107107
printk("%s\n", buf);

0 commit comments

Comments
 (0)