Netfilter-Devel Archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Vitaly Chikunov <vt@altlinux.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [iptables PATCH] libxtables: Attenuate effects of functions' internal static buffers
Date: Thu, 11 Apr 2024 12:16:53 +0200	[thread overview]
Message-ID: <Zhe4le2MCzFVF-Og@orbyte.nwl.cc> (raw)
In-Reply-To: <20240409164910.5x6l35anvc36juca@altlinux.org>

On Tue, Apr 09, 2024 at 07:49:10PM +0300, Vitaly Chikunov wrote:
> Phil,
> 
> On Tue, Apr 09, 2024 at 05:14:04PM +0200, Phil Sutter wrote:
> > While functions returning pointers to internal static buffers have
> > obvious limitations, users are likely unaware how they call each other
> > internally and thus won't notice unsafe use. One such case is calling
> > both xtables_ipaddr_to_numeric() and xtables_ipmask_to_numeric() as
> > parameters for a single printf() call.
> > 
> > Defuse this trap by avoiding the internal calls to
> > xtables_ip{,6}addr_to_numeric() which is easily doable since callers
> > keep their own static buffers already.
> > 
> > While being at it, make use of inet_ntop() everywhere and also use
> > INET_ADDRSTRLEN/INET6_ADDRSTRLEN defines for correct (and annotated)
> > static buffer sizes.
> > 
> > Reported-by: Vitaly Chikunov <vt@altlinux.org>
> > Signed-off-by: Phil Sutter <phil@nwl.cc>
> 
> Reviewed-by: Vitaly Chikunov <vt@altlinux.org>
> 
> Also, I tested in our build env and it's worked good.

Thanks for the review and testing, patch applied.

      reply	other threads:[~2024-04-11 10:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09 15:14 [iptables PATCH] libxtables: Attenuate effects of functions' internal static buffers Phil Sutter
2024-04-09 16:49 ` Vitaly Chikunov
2024-04-11 10:16   ` Phil Sutter [this message]

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=Zhe4le2MCzFVF-Og@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=vt@altlinux.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 read-only IMAP folder(s) and NNTP newsgroup(s).