]> git.ipfire.org Git - thirdparty/nftables.git/commit
src: fix memory leak when listing rules
authorEric Leblond <eric@regit.org>
Mon, 10 Jul 2017 22:32:49 +0000 (00:32 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 17 Jul 2017 15:20:33 +0000 (17:20 +0200)
commitdb4ca92225cca8571af82c6b515f8d7b0d9fd591
tree3ea47adcfd7f579932fe8e7c3266e1fa556784e5
parentd2b93afad7a67840d16d424b3cf5ce5255fca7ad
src: fix memory leak when listing rules

When listing rules we were calling strdup on the table name
but variable was just used locally.

Found via `nft list ruleset` run with ASAN:

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x45cca0 in __interceptor_strdup (/usr/local/sbin/nft+0x45cca0)
    #1 0x593c71 in xstrdup /home/eric/git/netfilter/nftables/src/utils.c:75:8
    #2 0x513b34 in do_list_ruleset /home/eric/git/netfilter/nftables/src/rule.c:1388:23
    #3 0x50e178 in do_command_list /home/eric/git/netfilter/nftables/src/rule.c:1500:10
    #4 0x50d3ea in do_command /home/eric/git/netfilter/nftables/src/rule.c:1696:10
    #5 0x5061ae in nft_netlink /home/eric/git/netfilter/nftables/src/main.c:207:9
    #6 0x505b87 in nft_run /home/eric/git/netfilter/nftables/src/main.c:255:8
    #7 0x50771f in main /home/eric/git/netfilter/nftables/src/main.c:392:6
    #8 0x7fa1f326d2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)

Signed-off-by: Eric Leblond <eric@regit.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/rule.c