netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: "Carlos Falgueras García" <carlosfg@riseup.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH libnftnl, v2] fix some error checking in parser functions
Date: Wed, 22 Jun 2016 19:30:05 +0200	[thread overview]
Message-ID: <20160622173005.GA4634@salvia> (raw)
In-Reply-To: <20160622172434.GA3755@salvia>

On Wed, Jun 22, 2016 at 07:24:34PM +0200, Pablo Neira Ayuso wrote:
> On Mon, Jun 20, 2016 at 12:29:19PM +0200, Carlos Falgueras García wrote:
> > Use a variable 'ret' multiple times without treat the error between can
> > overwrite the previous error value, and may execute code which should not.
> 
> Applied, thanks.

I had to apply this chunk on top. Note that these two don't set 'ret'.

diff --git a/src/set_elem.c b/src/set_elem.c
index 94b50f9..00b7327 100644
--- a/src/set_elem.c
+++ b/src/set_elem.c
@@ -393,8 +393,10 @@ static int nftnl_set_elems_parse2(struct
nftnl_set *s, const struct nlattr *nest
         }
        if (tb[NFTA_SET_ELEM_EXPR]) {
                e->expr = nftnl_expr_parse(tb[NFTA_SET_ELEM_EXPR]);
-               if (e->expr == NULL)
+               if (e->expr == NULL) {
+                       ret = -1;
                        goto out_set_elem;
+               }
                e->flags |= (1 << NFTNL_SET_ELEM_EXPR);
        }
        if (tb[NFTA_SET_ELEM_USERDATA]) {
@@ -406,8 +408,10 @@ static int nftnl_set_elems_parse2(struct
nftnl_set *s, const struct nlattr *nest
 
                e->user.len  =
mnl_attr_get_payload_len(tb[NFTA_SET_ELEM_USERDATA]);
                e->user.data = malloc(e->user.len);
-               if (e->user.data == NULL)
+               if (e->user.data == NULL) {
+                       ret = -1;
                        goto out_expr;
+               }
                memcpy(e->user.data, udata, e->user.len);
          
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2016-06-22 17:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20 10:29 [PATCH libnftnl, v2] fix some error checking in parser functions Carlos Falgueras García
2016-06-22 17:24 ` Pablo Neira Ayuso
2016-06-22 17:30   ` Pablo Neira Ayuso [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=20160622173005.GA4634@salvia \
    --to=pablo@netfilter.org \
    --cc=carlosfg@riseup.net \
    --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 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).