From: Phil Sutter <phil@nwl.cc>
To: Fernando Fernandez Mancera <ffmancera@riseup.net>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH 2/2] nfnl_osf: Silence string truncation gcc warnings
Date: Sun, 21 Jul 2019 13:29:13 +0200 [thread overview]
Message-ID: <20190721112913.GF22661@orbyte.nwl.cc> (raw)
In-Reply-To: <bb559c36-00f3-b295-ed61-6d1ae7d52b58@riseup.net>
Hi,
On Sun, Jul 21, 2019 at 01:15:58PM +0200, Fernando Fernandez Mancera wrote:
[...]
> > pend = nf_osf_strchr(pbeg, OSFPDEL);
> > if (pend) {
> > *pend = '\0';
> > + i = sizeof(f.genre);
> > if (pbeg[0] == '@' || pbeg[0] == '*')
> > - cnt = snprintf(f.genre, sizeof(f.genre), "%s", pbeg + 1);
> > - else
> > - cnt = snprintf(f.genre, sizeof(f.genre), "%s", pbeg);
> > + pbeg++;
> > + cnt = snprintf(f.genre, i, "%.*s", i - 1, pbeg + 1);
> > pbeg = pend + 1;
> > }
>
> I am not including this because the pbeg pointer is being modified if
> the condition is true which is not what we want. Note that pbeg is being
> used below. Also, we cannot do pbeg++ and at the same time shift the
> pointer passed to snprintf with pbeg + 1.
Oh, sorry that 'pbeg + 1' in my added code is a bug. I guess
incrementing pbeg if it starts with @ or * is fine because after the
call to snprintf() it is reset ('pbeg = pend + 1') without reusing its
old value.
Cheers, Phil
next prev parent reply other threads:[~2019-07-21 11:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-20 18:52 [nft PATCH 1/2] parser_bison: Get rid of (most) bison compiler warnings Phil Sutter
2019-07-20 18:52 ` [nft PATCH 2/2] nfnl_osf: Silence string truncation gcc warnings Phil Sutter
2019-07-20 19:36 ` Florian Westphal
2019-07-20 20:22 ` Phil Sutter
2019-07-21 11:15 ` Fernando Fernandez Mancera
2019-07-21 11:29 ` Phil Sutter [this message]
2019-07-20 19:43 ` [nft PATCH 1/2] parser_bison: Get rid of (most) bison compiler warnings Florian Westphal
2019-07-20 20:13 ` Phil Sutter
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=20190721112913.GF22661@orbyte.nwl.cc \
--to=phil@nwl.cc \
--cc=ffmancera@riseup.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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