Skip to contentSkip to conversation

xtables: fix memory leak in command_jump

PATCH In review Ana Rey 1 participant 2 messages Dec 2, 2013 – Dec 3, 2013 netfilter

lore
Share & tools
lore

Ana Rey

author
#0 lore raw

PATCH 1/1 xtables: fix memory leak in command_jump

This error is shown with valgrind tool:

valgrind --leak-check=full xtables -A INPUT -i eth0 -p tcp --dport 80

==7377==
==7377== 40 bytes in 1 blocks are still reachable in loss record 4 of 14

==7377==    at 0x4C2B514: calloc (vg_replace_malloc.c:593)
==7377==    by 0x52448C8: xtables_calloc (xtables.c:272)
==7377==    by 0x41487B: do_commandx (xtables.c:618)
==7377==    by 0x4134DC: xtables_main (xtables-standalone.c:72)
==7377==    by 0x5B87994: (below main) (libc-start.c:260)
==7377==
---
 iptables/xtables.c | 2 ++
 1 file changed, 2 insertions(+)
iptables/xtables.c +2 -0
index c49b4a2..b5fff8c 100644
@@ -638,6 +638,8 @@ static void command_jump(struct iptables_command_state *cs)
 		opts = xtables_merge_options(xtables_globals.orig_opts, opts,
 					     cs->target->extra_opts,
 					     &cs->target->option_offset);
+	free(cs->target->t);
+
 	if (opts == NULL)
 		xtables_error(OTHER_PROBLEM, "can't alloc memory!");
 }
Signature · 1 line
1.8.4.rc3
author
#1 lore raw

2013/12/2 Ana Rey <[email protected]>:

Quoted 4 lines

This error is shown with valgrind tool:

valgrind --leak-check=full xtables -A INPUT -i eth0 -p tcp --dport 80

Quoted 8 lines

==7377==
==7377== 40 bytes in 1 blocks are still reachable in loss record 4 of 14

==7377==    at 0x4C2B514: calloc (vg_replace_malloc.c:593)
==7377==    by 0x52448C8: xtables_calloc (xtables.c:272)
==7377==    by 0x41487B: do_commandx (xtables.c:618)
==7377==    by 0x4134DC: xtables_main (xtables-standalone.c:72)
==7377==    by 0x5B87994: (below main) (libc-start.c:260)

==7377==

Please, withdraw this patch, I detected a problem in it.

Quoted 20 lines
---
 iptables/xtables.c | 2 ++
 1 file changed, 2 insertions(+)
iptables/xtables.c +2 -1
index c49b4a2..b5fff8c 100644
@@ -638,6 +638,8 @@ static void command_jump(struct iptables_command_state *cs)
                opts = xtables_merge_options(xtables_globals.orig_opts, opts,
                                             cs->target->extra_opts,
                                             &cs->target->option_offset);
+       free(cs->target->t);
+
        if (opts == NULL)
                xtables_error(OTHER_PROBLEM, "can't alloc memory!");
 }
--

1.8.4.rc3

Signature · 3 lines
Ana Rey (@anaRB)
http://www.anarey.info
http://about.me/anarey