lkml.org 
[lkml]   [2020]   [Apr]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/9] efi/cper: Use scnprintf() for avoiding potential buffer overflow
    Date
    From: Takashi Iwai <tiwai@suse.de>

    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/20200311072145.5001-1-tiwai@suse.de
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    ---
    drivers/firmware/efi/cper.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
    index b1af0de2e100..9d2512913d25 100644
    --- a/drivers/firmware/efi/cper.c
    +++ b/drivers/firmware/efi/cper.c
    @@ -101,7 +101,7 @@ void cper_print_bits(const char *pfx, unsigned int bits,
    if (!len)
    len = snprintf(buf, sizeof(buf), "%s%s", pfx, str);
    else
    - len += snprintf(buf+len, sizeof(buf)-len, ", %s", str);
    + len += scnprintf(buf+len, sizeof(buf)-len, ", %s", str);
    }
    if (len)
    printk("%s\n", buf);
    --
    2.17.1
    \
     
     \ /
      Last update: 2020-04-09 15:05    [W:2.997 / U:0.288 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site