From: David Laight <David.Laight@ACULAB.COM>
To: 'Denis Kirjanov' <dkirjanov@suse.de>,
'Stephen Hemminger' <stephen@networkplumber.org>,
Denis Kirjanov <kirjanov@gmail.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: [PATCH iproute2] ifstat: convert sprintf to snprintf
Date: Fri, 2 Feb 2024 13:02:32 +0000 [thread overview]
Message-ID: <d2e9ab2c4df04f0e8f12b623366123eb@AcuMS.aculab.com> (raw)
In-Reply-To: <5fa65887-1f56-4470-bc99-383fe7e3f47b@suse.de>
From: Denis Kirjanov
> Sent: 02 February 2024 12:24
>
> On 2/2/24 14:32, David Laight wrote:
> > From: Stephen Hemminger
> >> Sent: 31 January 2024 16:14
> >
> >>
> >> On Wed, 31 Jan 2024 07:41:07 -0500
> >> Denis Kirjanov <kirjanov@gmail.com> wrote:
> >>
> >>> @@ -893,7 +893,7 @@ int main(int argc, char *argv[])
> >>>
> >>> sun.sun_family = AF_UNIX;
> >>> sun.sun_path[0] = 0;
> >>> - sprintf(sun.sun_path+1, "ifstat%d", getuid());
> >>> + snprintf(sun.sun_path+1, sizeof(sun.sun_path), "ifstat%d", getuid());
> >>
> >> If you are changing the line, please add spaces around plus sign
> >
> > Isn't the size also wrong - needs a matching '- 1'.
>
> I don't think it's wrong, it's just the size of the target buffer which is
> UNIX_PATH_MAX bytes.
But you are starting one byte in.
So, if the size were 8 the '\0' would be written after the end.
Also, to avoid the next patch in a few weeks it should be
calling scnprintf().
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2024-02-02 13:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 12:41 [PATCH iproute2] ifstat: convert sprintf to snprintf Denis Kirjanov
2024-01-31 16:14 ` Stephen Hemminger
2024-02-02 11:32 ` David Laight
2024-02-02 12:23 ` Denis Kirjanov
2024-02-02 13:02 ` David Laight [this message]
2024-02-02 13:28 ` 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=d2e9ab2c4df04f0e8f12b623366123eb@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=dkirjanov@suse.de \
--cc=kirjanov@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.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).