]> Git Repo - linux.git/commitdiff
ACPI: PCI: Use scnprintf() for avoiding potential buffer overflow
authorTakashi Iwai <[email protected]>
Wed, 11 Mar 2020 07:09:58 +0000 (08:09 +0100)
committerRafael J. Wysocki <[email protected]>
Sat, 14 Mar 2020 10:15:10 +0000 (11:15 +0100)
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: Rafael J. Wysocki <[email protected]>
drivers/acpi/pci_root.c

index d1e666ef3fcc886eb48772419aa891b78b039bc6..f92df2533e7ec8331dc7875efccdd9bef00b3a9f 100644 (file)
@@ -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);
This page took 0.083784 seconds and 4 git commands to generate.