netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: David Ahern <dsahern@gmail.com>
Cc: Denis Kirjanov <kirjanov@gmail.com>,
	netdev@vger.kernel.org, Denis Kirjanov <dkirjanov@suse.de>
Subject: Re: [PATCH v2 iproute2] ifstat: convert sprintf to snprintf
Date: Tue, 6 Feb 2024 19:13:35 -0800	[thread overview]
Message-ID: <20240206191335.27e2b869@hermes.local> (raw)
In-Reply-To: <fa61cd41-a0ec-4b01-aa2e-577a1b15cef3@gmail.com>

On Tue, 6 Feb 2024 18:05:52 -0700
David Ahern <dsahern@gmail.com> wrote:

> On 2/2/24 2:35 AM, Denis Kirjanov 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());  
> 
> sizeof(sun.sun_path) - 1 since the start is +1?
> 
> and that is an odd path. Stephen do you know the origin of
> "\0ifstat<uid>" for the path?


Yes that is abstract unix domain socket address.
Which avoids many issues with filesystem based Unix domain sockets.

  reply	other threads:[~2024-02-07  3:13 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 [this message]
2024-02-10 20:33 ` Stephen Hemminger
2024-02-11  8:39   ` Denis Kirjanov
2024-02-11 17:18     ` Stephen Hemminger
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=20240206191335.27e2b869@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=dkirjanov@suse.de \
    --cc=dsahern@gmail.com \
    --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).