netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [libnftnl PATCH] chain: fix segfault in 'device' XML parsing
@ 2015-10-13  7:39 Arturo Borrero Gonzalez
  2015-10-13  9:40 ` Arturo Borrero Gonzalez
  2015-10-13 10:07 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: Arturo Borrero Gonzalez @ 2015-10-13  7:39 UTC (permalink / raw)
  To: netfilter-devel

Reported by valgrind:
[...]
==14065== Process terminating with default action of signal 11 (SIGSEGV)
==14065==  Access not within mapped region at address 0x0
==14065==    at 0x4C2C022: strlen (vg_replace_strmem.c:454)
==14065==    by 0x4E41A93: nftnl_chain_set_str (chain.c:259)
==14065==    by 0x4E427F7: nftnl_mxml_chain_parse (chain.c:770)
==14065==    by 0x4E48F96: nftnl_ruleset_parse_chains (ruleset.c:314)
==14065==    by 0x4E4959A: nftnl_ruleset_xml_parse_ruleset (ruleset.c:625)
==14065==    by 0x4E4959A: nftnl_ruleset_xml_parse_cmd (ruleset.c:668)
==14065==    by 0x4E4959A: nftnl_ruleset_xml_parse (ruleset.c:706)
==14065==    by 0x4E4959A: nftnl_ruleset_do_parse (ruleset.c:734)
==14065==    by 0x4013C9: test_xml (nft-parsing-test.c:166)
==14065==    by 0x4016F4: execute_test (nft-parsing-test.c:214)
==14065==    by 0x400EBA: main (nft-parsing-test.c:330)
[...]

While at it, fix a bit the coding style.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 src/chain.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/chain.c b/src/chain.c
index 8a8e8b8..2b44a31 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -763,10 +763,10 @@ int nftnl_mxml_chain_parse(mxml_node_t *tree, struct nftnl_chain *c,
 			nftnl_chain_set_u32(c, NFTNL_CHAIN_POLICY,
 					       policy);
 		}
-		dev = nftnl_mxml_str_parse(tree, "device", MXML_DESCEND_FIRST,
-					 NFTNL_XML_MAND, err);
 
-		if (table != NULL)
+		dev = nftnl_mxml_str_parse(tree, "device", MXML_DESCEND_FIRST,
+					   NFTNL_XML_MAND, err);
+		if (dev != NULL)
 			nftnl_chain_set_str(c, NFTNL_CHAIN_DEV, dev);
 	}
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [libnftnl PATCH] chain: fix segfault in 'device' XML parsing
  2015-10-13  7:39 [libnftnl PATCH] chain: fix segfault in 'device' XML parsing Arturo Borrero Gonzalez
@ 2015-10-13  9:40 ` Arturo Borrero Gonzalez
  2015-10-13 10:07 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Arturo Borrero Gonzalez @ 2015-10-13  9:40 UTC (permalink / raw)
  To: Netfilter Development Mailing list

On 13 October 2015 at 09:39, Arturo Borrero Gonzalez
<arturo.borrero.glez@gmail.com> wrote:
> Reported by valgrind:
> [...]
> ==14065== Process terminating with default action of signal 11 (SIGSEGV)
> ==14065==  Access not within mapped region at address 0x0
> ==14065==    at 0x4C2C022: strlen (vg_replace_strmem.c:454)
> ==14065==    by 0x4E41A93: nftnl_chain_set_str (chain.c:259)
> ==14065==    by 0x4E427F7: nftnl_mxml_chain_parse (chain.c:770)
> ==14065==    by 0x4E48F96: nftnl_ruleset_parse_chains (ruleset.c:314)
> ==14065==    by 0x4E4959A: nftnl_ruleset_xml_parse_ruleset (ruleset.c:625)
> ==14065==    by 0x4E4959A: nftnl_ruleset_xml_parse_cmd (ruleset.c:668)
> ==14065==    by 0x4E4959A: nftnl_ruleset_xml_parse (ruleset.c:706)
> ==14065==    by 0x4E4959A: nftnl_ruleset_do_parse (ruleset.c:734)
> ==14065==    by 0x4013C9: test_xml (nft-parsing-test.c:166)
> ==14065==    by 0x4016F4: execute_test (nft-parsing-test.c:214)
> ==14065==    by 0x400EBA: main (nft-parsing-test.c:330)
> [...]
>
> While at it, fix a bit the coding style.
>
> Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> ---
>  src/chain.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>

BTW this was reported by the Debian CI system [0].

[0] http://ci.debian.net/packages/libn/libnftnl/unstable/amd64/
-- 
Arturo Borrero González
--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [libnftnl PATCH] chain: fix segfault in 'device' XML parsing
  2015-10-13  7:39 [libnftnl PATCH] chain: fix segfault in 'device' XML parsing Arturo Borrero Gonzalez
  2015-10-13  9:40 ` Arturo Borrero Gonzalez
@ 2015-10-13 10:07 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2015-10-13 10:07 UTC (permalink / raw)
  To: Arturo Borrero Gonzalez; +Cc: netfilter-devel

On Tue, Oct 13, 2015 at 09:39:10AM +0200, Arturo Borrero Gonzalez wrote:
> Reported by valgrind:
> [...]
> ==14065== Process terminating with default action of signal 11 (SIGSEGV)
> ==14065==  Access not within mapped region at address 0x0
> ==14065==    at 0x4C2C022: strlen (vg_replace_strmem.c:454)
> ==14065==    by 0x4E41A93: nftnl_chain_set_str (chain.c:259)
> ==14065==    by 0x4E427F7: nftnl_mxml_chain_parse (chain.c:770)
> ==14065==    by 0x4E48F96: nftnl_ruleset_parse_chains (ruleset.c:314)
> ==14065==    by 0x4E4959A: nftnl_ruleset_xml_parse_ruleset (ruleset.c:625)
> ==14065==    by 0x4E4959A: nftnl_ruleset_xml_parse_cmd (ruleset.c:668)
> ==14065==    by 0x4E4959A: nftnl_ruleset_xml_parse (ruleset.c:706)
> ==14065==    by 0x4E4959A: nftnl_ruleset_do_parse (ruleset.c:734)
> ==14065==    by 0x4013C9: test_xml (nft-parsing-test.c:166)
> ==14065==    by 0x4016F4: execute_test (nft-parsing-test.c:214)
> ==14065==    by 0x400EBA: main (nft-parsing-test.c:330)
> [...]
> 
> While at it, fix a bit the coding style.

Applied, thanks Arturo.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-13 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-13  7:39 [libnftnl PATCH] chain: fix segfault in 'device' XML parsing Arturo Borrero Gonzalez
2015-10-13  9:40 ` Arturo Borrero Gonzalez
2015-10-13 10:07 ` Pablo Neira Ayuso

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).