summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2024-07-10 15:25:58 +0200
committerFlorian Westphal <fw@strlen.de>2024-07-10 16:41:25 +0200
commitafa77c18f65ebed1036fb8c8cfd15e8a8faa0254 (patch)
treedad92502696f7603eec9a139ff3b2a5dadc479a8
parentac77f3805c71f14c51730a9c5cb726ee67f14159 (diff)
libnftables: fix crash when freeing non-malloc'd address
dirname may return static pointer: munmap_chunk(): invalid pointer 20508 Aborted nft -f test Fixes: 6ef04f99382c ("libnftables: search for default include path last") Signed-off-by: Florian Westphal <fw@strlen.de>
-rw-r--r--src/libnftables.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libnftables.c b/src/libnftables.c
index af4734c0..586f8fde 100644
--- a/src/libnftables.c
+++ b/src/libnftables.c
@@ -789,12 +789,12 @@ static int nft_run_optimized_file(struct nft_ctx *nft, const char *filename)
static int nft_ctx_add_basedir_include_path(struct nft_ctx *nft,
const char *filename)
{
- const char *basedir = dirname(xstrdup(filename));
+ char *basedir = xstrdup(filename);
int ret;
- ret = nft_ctx_add_include_path(nft, basedir);
+ ret = nft_ctx_add_include_path(nft, dirname(basedir));
- free_const(basedir);
+ free(basedir);
return ret;
}