From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft] libnftables: fix crash when freeing non-malloc'd address
Date: Wed, 10 Jul 2024 15:31:44 +0200 [thread overview]
Message-ID: <20240710133146.14287-1-fw@strlen.de> (raw)
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>
---
src/libnftables.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/libnftables.c b/src/libnftables.c
index af4734c05004..586f8fdede76 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;
}
--
2.44.2
next reply other threads:[~2024-07-10 13:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-10 13:31 Florian Westphal [this message]
2024-07-10 14:01 ` [PATCH nft] libnftables: fix crash when freeing non-malloc'd address Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240710133146.14287-1-fw@strlen.de \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox