From: Arturo Borrero <arturo.borrero.glez@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org
Subject: [libnftables PATCH 2/3] nat: xml: fix non-mandatory element
Date: Sat, 15 Jun 2013 03:16:10 +0200 [thread overview]
Message-ID: <20130615011610.3778.37555.stgit@nfdev.cica.es> (raw)
In-Reply-To: <20130615011603.3778.67261.stgit@nfdev.cica.es>
If the node isn't present, this produces segfault.
Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
src/expr/nat.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/expr/nat.c b/src/expr/nat.c
index cd38e83..a76f5b5 100644
--- a/src/expr/nat.c
+++ b/src/expr/nat.c
@@ -258,7 +258,7 @@ static int nft_rule_expr_nat_xml_parse(struct nft_rule_expr *e, char *xml)
/* Get and set <sreg_addr_min_v4>. Not mandatory */
node = mxmlFindElement(tree, tree, "sreg_addr_min_v4", NULL, NULL,
MXML_DESCEND);
- if (node == NULL) {
+ if (node != NULL) {
tmp = strtoull(node->child->value.opaque, &endptr, 10);
if (tmp > UINT32_MAX || tmp < 0 || *endptr)
goto err;
@@ -270,7 +270,7 @@ static int nft_rule_expr_nat_xml_parse(struct nft_rule_expr *e, char *xml)
/* Get and set <sreg_addr_max_v4>. Not mandatory */
node = mxmlFindElement(tree, tree, "sreg_addr_max_v4", NULL, NULL,
MXML_DESCEND);
- if (node == NULL) {
+ if (node != NULL) {
tmp = strtoull(node->child->value.opaque, &endptr, 10);
if (tmp > UINT32_MAX || tmp < 0 || *endptr)
goto err;
@@ -282,7 +282,7 @@ static int nft_rule_expr_nat_xml_parse(struct nft_rule_expr *e, char *xml)
/* Get and set <sreg_proto_min>. Not mandatory */
node = mxmlFindElement(tree, tree, "sreg_proto_min", NULL, NULL,
MXML_DESCEND);
- if (node == NULL) {
+ if (node != NULL) {
tmp = strtoull(node->child->value.opaque, &endptr, 10);
if (tmp > UINT32_MAX || tmp < 0 || *endptr)
goto err;
@@ -294,7 +294,7 @@ static int nft_rule_expr_nat_xml_parse(struct nft_rule_expr *e, char *xml)
/* Get and set <sreg_proto_max>. Not mandatory */
node = mxmlFindElement(tree, tree, "sreg_proto_max", NULL, NULL,
MXML_DESCEND);
- if (node == NULL) {
+ if (node != NULL) {
tmp = strtoull(node->child->value.opaque, &endptr, 10);
if (tmp > UINT32_MAX || tmp < 0 || *endptr)
goto err;
next prev parent reply other threads:[~2013-06-15 1:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-15 1:16 [libnftables PATCH 1/3] nat: xml: fix xml_snprintf buffer offset Arturo Borrero
2013-06-15 1:16 ` Arturo Borrero [this message]
2013-06-17 19:28 ` [libnftables PATCH 2/3] nat: xml: fix non-mandatory element Pablo Neira Ayuso
2013-06-15 1:16 ` [libnftables PATCH 3/3] rule: xml: delete trailing space Arturo Borrero
2013-06-17 19:28 ` Pablo Neira Ayuso
2013-06-17 19:28 ` [libnftables PATCH 1/3] nat: xml: fix xml_snprintf buffer offset 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=20130615011610.3778.37555.stgit@nfdev.cica.es \
--to=arturo.borrero.glez@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).