From: Stephen Hemminger <stephen@networkplumber.org>
To: Denis Kirjanov <dkirjanov@suse.de>
Cc: Denis Kirjanov <kirjanov@gmail.com>, netdev@vger.kernel.org
Subject: Re: [PATCH v2 iproute2] ifstat: convert sprintf to snprintf
Date: Sun, 11 Feb 2024 09:18:02 -0800 [thread overview]
Message-ID: <20240211091802.21885973@hermes.local> (raw)
In-Reply-To: <331c1b3b-4dbe-48e7-9e75-0536528a8868@suse.de>
On Sun, 11 Feb 2024 11:39:13 +0300
Denis Kirjanov <dkirjanov@suse.de> wrote:
> On 2/10/24 23:33, Stephen Hemminger wrote:
> > On Fri, 2 Feb 2024 04:35:27 -0500
> > Denis Kirjanov <kirjanov@gmail.com> wrote:
> >
> >> Use snprintf to print only valid data
> >>
> >> v2: adjust formatting
> >>
> >> Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
> >> ---
> >
> > Tried this but compile failed
> >
> > ifstat.c:896:2: warning: 'snprintf' size argument is too large; destination buffer has size 107, but size argument is 108 [-Wfortify-source]
> > snprintf(sun.sun_path + 1, sizeof(sun.sun_path), "ifstat%d", getuid());
>
> Right, this is addressed in the patch with scnprintf
>
But I see no need to convert to scnprintf(). Scnprintf is about the return value
and almost nowhere in iproute2 uses the return value and those that to look at the
return value are checking for beyond buffer. Plus if you convert to scnprintf you
lose lots of the fortify and other analyzer checking.
Bottom line scnprintf() makes sense in kernel but not iproute2.
next prev parent reply other threads:[~2024-02-11 17:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 9:35 [PATCH v2 iproute2] ifstat: convert sprintf to snprintf Denis Kirjanov
2024-02-07 1:05 ` David Ahern
2024-02-07 3:13 ` Stephen Hemminger
2024-02-10 20:33 ` Stephen Hemminger
2024-02-11 8:39 ` Denis Kirjanov
2024-02-11 17:18 ` Stephen Hemminger [this message]
2024-02-11 18:10 ` Denis Kirjanov
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=20240211091802.21885973@hermes.local \
--to=stephen@networkplumber.org \
--cc=dkirjanov@suse.de \
--cc=kirjanov@gmail.com \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).