rule: memleak of list of timeout policies
Pablo Neira Ayuso
maintainerPATCH 1/1 rule: memleak of list of timeout policies
Release list of ct timeout policy when object is freed.
Direct leak of 160 byte(s) in 2 object(s) allocated from:
#0 0x7fc0273ad330 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7fc0231377c4 in xmalloc /home/.../devel/nftables/src/utils.c:36
#2 0x7fc023137983 in xzalloc /home/.../devel/nftables/src/utils.c:75
#3 0x7fc0231f64d6 in nft_parse /home/.../devel/nftables/src/parser_bison.y:4448Signed-off-by Pablo Neira Ayuso <[email protected]>
---
After this update tests/py shows only memleaks in Python and there is still one small string memleak in the parser that I didn't find yet.
src/netlink.c | 1 + src/parser_bison.y | 1 + src/rule.c | 8 ++++++++ 3 files changed, 10 insertions(+)
src/netlink.c +1 -0
@@ -1484,6 +1484,7 @@ struct obj *netlink_delinearize_obj(struct netlink_ctx *ctx, obj->ct_helper.l4proto =nftnl_obj_get_u8 (nlo,NFTNL_OBJ_CT_HELPER_L4PROTO );break ;case NFT_OBJECT_CT_TIMEOUT : +init_list_head (&obj->ct_timeout.timeout_list); obj->ct_timeout.l3proto =nftnl_obj_get_u16 (nlo,NFTNL_OBJ_CT_TIMEOUT_L3PROTO ); obj->ct_timeout.l4proto =nftnl_obj_get_u8 (nlo,NFTNL_OBJ_CT_TIMEOUT_L4PROTO ); memcpy(obj->ct_timeout.timeout,
src/parser_bison.y +1 -0
@@ -1748,6 +1748,7 @@ table_block : /* empty */ { $$ = $<table>-1; } { $5->location = @4; $5->type = NFT_OBJECT_CT_TIMEOUT; + init_list_head(&$5->ct_timeout.timeout_list); handle_merge(&$5->handle, &$4); handle_free(&$4); list_add_tail(&$5->list, &$1->objs);
src/rule.c +8 -0
@@ -1709,6 +1709,14 @@ void obj_free(struct obj *obj)return ;xfree (obj->comment);handle_free (&obj->handle); +if (obj->type ==NFT_OBJECT_CT_TIMEOUT ) { +struct timeout_state *ts, *next; + +list_for_each_entry_safe (ts, next, &obj->ct_timeout.timeout_list, head) { +list_del (&ts->head); +xfree (ts); + } + }xfree (obj); }
Signature · 1 line
2.20.1