public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jamal Hadi Salim <jhs@mojatatu.com>
To: stephen@networkplumber.org
Cc: netdev@vger.kernel.org, dsahern@gmail.com, aclaudi@redhat.com,
	daniel@iogearbox.net, Jamal Hadi Salim <hadi@mojatatu.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>
Subject: [PATCH iproute2 1/1] bpf: Fix segfault when custom pinning is used
Date: Tue, 21 Apr 2020 14:04:26 -0400	[thread overview]
Message-ID: <20200421180426.6945-1-jhs@emojatatu.com> (raw)

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


             reply	other threads:[~2020-04-21 18:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 18:04 Jamal Hadi Salim [this message]
2020-04-21 19:38 ` [PATCH iproute2 1/1] bpf: Fix segfault when custom pinning is used 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

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=20200421180426.6945-1-jhs@emojatatu.com \
    --to=jhs@mojatatu.com \
    --cc=aclaudi@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=dsahern@gmail.com \
    --cc=hadi@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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