diff options
author | Liping Zhang <liping.zhang@spreadtrum.com> | 2016-07-16 19:39:53 +0800 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2016-07-16 13:46:31 +0200 |
commit | ebca5a8151a05969ed18c060799e099c9a599b08 (patch) | |
tree | 1a32ae012d4d7a84a29f0f04914249eb6055b779 /extensions/libxt_connlabel.c | |
parent | f035be35c749d5c5cbb7ffdbcd1c548b91bd3033 (diff) |
extensions: libxt_connlabel: fix crash when connlabel.conf is empty
When connlabel.conf is empty, nfct_labelmap_new will return NULL and
set errno to 0. So we will miss to check this situation, and cause NULL
deference in nfct_labelmap_get_bit.
Input the following commands will reproduce this crash:
# echo > /etc/xtables/connlabel.conf
# iptables -A INPUT -m connlabel --label abc
Segmentation fault (core dumped)
Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'extensions/libxt_connlabel.c')
-rw-r--r-- | extensions/libxt_connlabel.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/extensions/libxt_connlabel.c b/extensions/libxt_connlabel.c index 1f830954..355c99ae 100644 --- a/extensions/libxt_connlabel.c +++ b/extensions/libxt_connlabel.c @@ -38,9 +38,16 @@ static void connlabel_open(void) return; map = nfct_labelmap_new(NULL); - if (!map && errno) - xtables_error(RESOURCE_PROBLEM, "cannot open connlabel.conf: %s\n", - strerror(errno)); + if (map != NULL) + return; + + if (errno) { + xtables_error(RESOURCE_PROBLEM, + "cannot open connlabel.conf: %s", strerror(errno)); + } else { + xtables_error(RESOURCE_PROBLEM, + "cannot parse label, maybe valid label map is empty"); + } } static void connlabel_mt_parse(struct xt_option_call *cb) |