@@ -1509,15 +1509,15 @@ 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 = snprintf(tmp, PATH_MAX, "%s/../", bpf_get_work_dir(ctx->type));
if (ret < 0) {
- fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
- goto out;
+ fprintf(stderr, "snprintf failed: %s\n", strerror(errno));
+ return ret;
}
ret = asprintf(&rem, "%s/", todo);
@@ -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;
}