Skip to content

Commit

Permalink
ACPI: PCI: Use scnprintf() for avoiding potential buffer overflow
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Takashi Iwai authored and Rafael J. Wysocki committed Mar 14, 2020
1 parent 2c523b3 commit edd6608
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/acpi/pci_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static void decode_osc_bits(struct acpi_pci_root *root, char *msg, u32 word,
buf[0] = '\0';
for (i = 0, entry = table; i < size; i++, entry++)
if (word & entry->bit)
len += snprintf(buf + len, sizeof(buf) - len, "%s%s",
len += scnprintf(buf + len, sizeof(buf) - len, "%s%s",
len ? " " : "", entry->desc);

dev_info(&root->device->dev, "_OSC: %s [%s]\n", msg, buf);
Expand Down

0 comments on commit edd6608

Please sign in to comment.