lkml.org 
[lkml]   [2020]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] printk: Convert a use of sprintf to snprintf in console_unlock
On (20/01/30 15:16), Nathan Chancellor wrote:
> When CONFIG_PRINTK is disabled (e.g. when building allnoconfig), clang
> warns:
>
> ../kernel/printk/printk.c:2416:10: warning: 'sprintf' will always
> overflow; destination buffer has size 0, but format string expands to at
> least 33 [-Wfortify-source]
> len = sprintf(text,
> ^
> 1 warning generated.
>
> It is not wrong; text has a zero size when CONFIG_PRINTK is disabled
> because LOG_LINE_MAX and PREFIX_MAX are both zero. Change to snprintf so
> that this case is explicitly handled without any risk of overflow.

We probably can add a note here that for !CONFIG_PRINTK builds
logbuf overflow is very unlikely.

Otherwise,
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

-ss

\
 
 \ /
  Last update: 2020-01-31 08:03    [W:0.224 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site