]> git.ipfire.org Git - thirdparty/iptables.git/commit
iptables: Plug memleaks in print_firewall()
authorPhil Sutter <phil@nwl.cc>
Fri, 25 Nov 2022 20:35:28 +0000 (21:35 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 2 Dec 2022 00:44:17 +0000 (01:44 +0100)
commitfb63f8b7337aa11a667537e6a3b399062ede2eb5
tree8e8385774053d458c48251f4bd2973eecfc8783f
parentaa0c54030300441e9fd66c7016d0090f6736d449
iptables: Plug memleaks in print_firewall()

When adding a rule in verbose mode, valgrind prints:

192 bytes in 1 blocks are definitely lost in loss record 1 of 2
   at 0x48417E5: malloc (vg_replace_malloc.c:381)
   by 0x486B158: xtables_malloc (xtables.c:446)
   by 0x486C1F6: xtables_find_match (xtables.c:826)
   by 0x10E684: print_match (iptables.c:115)
   by 0x10E684: print_firewall (iptables.c:169)
   by 0x10FC0C: print_firewall_line (iptables.c:196)
   by 0x10FC0C: append_entry (iptables.c:221)
   by 0x10FC0C: do_command4 (iptables.c:776)
   by 0x10E45B: iptables_main (iptables-standalone.c:59)
   by 0x49A2349: (below main) (in /lib64/libc.so.6)

200 bytes in 1 blocks are definitely lost in loss record 2 of 2
   at 0x48417E5: malloc (vg_replace_malloc.c:381)
   by 0x486B158: xtables_malloc (xtables.c:446)
   by 0x486BBD6: xtables_find_target (xtables.c:956)
   by 0x10E579: print_firewall (iptables.c:145)
   by 0x10FC0C: print_firewall_line (iptables.c:196)
   by 0x10FC0C: append_entry (iptables.c:221)
   by 0x10FC0C: do_command4 (iptables.c:776)
   by 0x10E45B: iptables_main (iptables-standalone.c:59)
   by 0x49A2349: (below main) (in /lib64/libc.so.6)

If the match/target was cloned, it needs to be freed. Basically a bug since
day 1.

Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/ip6tables.c
iptables/iptables.c