lkml.org 
[lkml]   [2022]   [Jan]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] objtool: Fix -Wformat-truncation seen with GCC 12.
Date
From: Martin Liška
> Sent: 12 January 2022 09:29
>
> The patch fixes the following warning that seems reasonable:
>
> check.c:2836:58: error: '%d' directive output may be truncated writing between 1 and 10 bytes into a
> region of size 9 [-Werror=format-truncation=]
> 2836 | snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);

Looks pretty unreasonable to me :-)
The domain of 'idx' is much smaller than that of 'int'.
Indeed the overflow can only actually happen if it is negative.
By then all sorts of other things will have gone wrong.

OTOH changing 16 to 60 is one way to STFU.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
\
 
 \ /
  Last update: 2022-01-12 10:39    [W:0.032 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site