All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Cc: Ana Rey <anarey@gmail.com>,
	Netfilter Development Mailing list
	<netfilter-devel@vger.kernel.org>
Subject: Re: [libnftnl PATCH 2/5] src: set: Do not print unset values in xml
Date: Wed, 11 Jun 2014 19:49:01 +0200	[thread overview]
Message-ID: <20140611174901.GA17843@localhost> (raw)
In-Reply-To: <CAOkSjBjU6X1nZ1QY7TK08Ft22pZdSEQHmrrVxPWYCbUQuC+qrg@mail.gmail.com>

On Wed, Jun 11, 2014 at 06:14:40PM +0200, Arturo Borrero Gonzalez wrote:
> Hi Ana,
> 
> a small thing below,
> 
> On 11 June 2014 17:50, Ana Rey <anarey@gmail.com> wrote:
> [...]
> > @@ -563,17 +560,26 @@ static int nft_set_elem_snprintf_xml(char *buf, size_t size,
> >  {
> >         int ret, len = size, offset = 0, type = DATA_NONE;
> >
> > -       ret = snprintf(buf, size, "<set_elem>"
> > -                               "<flags>%u</flags><key>",
> > -                               e->set_elem_flags);
> > +       ret = snprintf(buf, size, "<set_elem>");
> >         SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
> >
> > -       ret = nft_data_reg_snprintf(buf+offset, len, &e->key,
> > -                                   NFT_OUTPUT_XML, flags, DATA_VALUE);
> > -       SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
> > +       if (e->flags & (1 << NFT_SET_ELEM_ATTR_FLAGS)) {
> > +               ret = snprintf(buf, size, "<flags>%u</flags>",
> > +                              e->set_elem_flags);
> 
> I think this snprintf call may overwrite the buffer, so you should use
> snprintf(buf+offset, len, ...)

Thanks for reviewing Arturo.

I have fixed this here and applied.

  reply	other threads:[~2014-06-11 17:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11 15:50 [libnftnl PATCH 0/5] Set: Do not print unset value Ana Rey
2014-06-11 15:50 ` [libnftnl PATCH 1/5] src: set: Use nft_rule_expr_set_* in the xml parsing code Ana Rey
2014-06-11 17:47   ` Pablo Neira Ayuso
2014-06-11 15:50 ` [libnftnl PATCH] tests: Use the system errors in test_xml Ana Rey
2014-06-11 17:48   ` Pablo Neira Ayuso
2014-06-11 15:50 ` [libnftnl PATCH 2/5] src: set: Do not print unset values in xml Ana Rey
2014-06-11 16:14   ` Arturo Borrero Gonzalez
2014-06-11 17:49     ` Pablo Neira Ayuso [this message]
2014-06-11 15:50 ` [libnftnl PATCH 3/5] src: set: Do not print unset values in json Ana Rey
2014-06-11 17:50   ` Pablo Neira Ayuso
2014-06-11 15:50 ` [libnftnl PATCH 4/5] src: set: Free memory in the same function that is reserved Ana Rey
2014-06-11 17:50   ` Pablo Neira Ayuso
2014-06-11 15:50 ` [libnftnl PATCH 5/5] tests: xmlfile: Test files without unset child elements in set elements Ana Rey
2014-06-11 17:51   ` Pablo Neira Ayuso

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=20140611174901.GA17843@localhost \
    --to=pablo@netfilter.org \
    --cc=anarey@gmail.com \
    --cc=arturo.borrero.glez@gmail.com \
    --cc=netfilter-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.