summaryrefslogtreecommitdiffstats
path: root/libxtables
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2024-01-31 14:58:17 +0100
committerPhil Sutter <phil@nwl.cc>2024-02-01 14:51:30 +0100
commite7366db80740d34d2fe4ba8d12ef86a423e66280 (patch)
tree9a5a951efb7f0c438563d363376e3cfc2ffcfb07 /libxtables
parent2026b08bce7fe87b5964f7912e1eef30f04922c1 (diff)
libxtables: Fix memleak of matches' udata
If the extension specifies a non-zero udata_size, field 'udata' points to an allocated buffer which needs to be freed upon extension deinit. Interestingly, this bug was identified by ASAN and missed by valgrind. Fixes: 2dba676b68ef8 ("extensions: support for per-extension instance "global" variable space") Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'libxtables')
-rw-r--r--libxtables/xtables.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index b4339e8d..856bfae8 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -1420,6 +1420,10 @@ void xtables_rule_matches_free(struct xtables_rule_match **matches)
free(matchp->match->m);
matchp->match->m = NULL;
}
+ if (matchp->match->udata_size) {
+ free(matchp->match->udata);
+ matchp->match->udata = NULL;
+ }
if (matchp->match == matchp->match->next) {
free(matchp->match);
matchp->match = NULL;