lkml.org 
[lkml]   [2022]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] objtool: check: give big enough buffer for pv_ops
On Fri, Jan 14, 2022 at 07:57:56AM +0000, Sergei Trofimovich wrote:
> On gcc-12 build fails flagging possible buffer overflow:
>
> check.c: In function 'validate_call':
> check.c:2865:58: error: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 9 [-Werror=format-truncation=]
> 2865 | snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);
> | ^~
>
> I think it's a valid warning:
>
> static char pvname[16];
> int idx;
> ...
> idx = (rel->addend / sizeof(void *));
> snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);
>
> we have only 7 chars for %d while it could take up to 9.

Right, very unlikely to have that many pv_ops, but it doesn't hurt to
fix this.

Thanks!

\
 
 \ /
  Last update: 2022-01-14 09:54    [W:0.081 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site