mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'Martin Liška'" <mliska@suse.cz>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] objtool: Fix -Wformat-truncation seen with GCC 12.
Date: Wed, 12 Jan 2022 09:38:40 +0000	[thread overview]
Message-ID: <8ccdb9b4c55b40ba984d4dc333f7a13c@AcuMS.aculab.com> (raw)
In-Reply-To: <5168172b-d6f2-a13b-5d43-175cd864ebe9@suse.cz>

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)

  reply	other threads:[~2022-01-12  9:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12  9:29 Martin Liška
2022-01-12  9:38 ` David Laight [this message]
2022-01-12  9:41 ` Miroslav Benes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ccdb9b4c55b40ba984d4dc333f7a13c@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mliska@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®