netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: netfilter-devel@vger.kernel.org
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH ipset 2/2] lib: don't segfault when ipset_data_get returns NULL
Date: Wed, 12 Feb 2014 10:27:20 +0100	[thread overview]
Message-ID: <1392197240-9389-2-git-send-email-fw@strlen.de> (raw)
In-Reply-To: <1392197240-9389-1-git-send-email-fw@strlen.de>

ipset_data_get returns NULL if the attribute is not available, causes when
running 'ipset list':

$ ipset -N foo hash:ip
$ ipset list
Segmentation fault (core dumped)

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 Not sure about this patch, the missing attr is IPSET_OPT_MEMSIZE.
 Is the kernel supposed to send it along (i am on latest nf tree)?

diff --git a/lib/print.c b/lib/print.c
index f81c074..9ad4bab 100644
--- a/lib/print.c
+++ b/lib/print.c
@@ -378,6 +378,8 @@ ipset_print_number(char *buf, unsigned int len,
 	assert(data);
 
 	number = ipset_data_get(data, opt);
+	if (!number)
+		return 0;
 	maxsize = ipset_data_sizeof(opt, AF_INET);
 	D("opt: %u, maxsize %zu", opt, maxsize);
 	if (maxsize == sizeof(uint8_t))
-- 
1.8.1.5


  reply	other threads:[~2014-02-12  9:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12  9:27 [PATCH ipset 1/2] lib: fix ifname 'physdev:' prefix parsing Florian Westphal
2014-02-12  9:27 ` Florian Westphal [this message]
2014-02-13 10:14   ` [PATCH ipset 2/2] lib: don't segfault when ipset_data_get returns NULL Jozsef Kadlecsik
2014-02-13 11:17     ` Florian Westphal
2014-02-13 11:31       ` Jozsef Kadlecsik
2014-02-13 10:10 ` [PATCH ipset 1/2] lib: fix ifname 'physdev:' prefix parsing Jozsef Kadlecsik
2014-02-13 11:01   ` Florian Westphal
2014-02-13 11:22     ` Jozsef Kadlecsik

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=1392197240-9389-2-git-send-email-fw@strlen.de \
    --to=fw@strlen.de \
    --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).