public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2 1/1] bpf: Fix segfault when custom pinning is used
@ 2020-04-21 18:04 Jamal Hadi Salim
  2020-04-21 19:38 ` Andrea Claudi
  2020-04-22  6:42 ` Dominique Martinet
  0 siblings, 2 replies; 6+ messages in thread
From: Jamal Hadi Salim @ 2020-04-21 18:04 UTC (permalink / raw)
  To: stephen
  Cc: netdev, dsahern, aclaudi, daniel, Jamal Hadi Salim,
	Jamal Hadi Salim

From: Jamal Hadi Salim <hadi@mojatatu.com>

Fixes: c0325b06382 ("bpf: replace snprintf with asprintf when dealing with long buffers")

Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
 lib/bpf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/bpf.c b/lib/bpf.c
index 10cf9bf4..cf636c9e 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -1509,12 +1509,12 @@ out:
 static int bpf_make_custom_path(const struct bpf_elf_ctx *ctx,
 				const char *todo)
 {
-	char *tmp = NULL;
+	char tmp[PATH_MAX] = {};
 	char *rem = NULL;
 	char *sub;
 	int ret;
 
-	ret = asprintf(&tmp, "%s/../", bpf_get_work_dir(ctx->type));
+	ret = sprintf(tmp, "%s/../", bpf_get_work_dir(ctx->type));
 	if (ret < 0) {
 		fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
 		goto out;
@@ -1547,7 +1547,6 @@ static int bpf_make_custom_path(const struct bpf_elf_ctx *ctx,
 	ret = 0;
 out:
 	free(rem);
-	free(tmp);
 	return ret;
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-22  9:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-21 18:04 [PATCH iproute2 1/1] bpf: Fix segfault when custom pinning is used Jamal Hadi Salim
2020-04-21 19:38 ` Andrea Claudi
2020-04-21 19:58   ` Jamal Hadi Salim
2020-04-21 22:10     ` Andrea Claudi
2020-04-22  6:42 ` Dominique Martinet
2020-04-22  9:47   ` Jamal Hadi Salim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox