diff options
author | Andrea Claudi <aclaudi@redhat.com> | 2021-08-07 18:57:38 +0200 |
---|---|---|
committer | Stephen Hemminger <stephen@networkplumber.org> | 2021-08-10 19:55:12 -0700 |
commit | 50a412702252ba29524b860df6c30d14f03cd34a (patch) | |
tree | 0cfa00e769a86b2cc0947daa818f61aeaaa761a0 | |
parent | 954a0077c83b7981271809391ac0712d24a48314 (diff) | |
download | iproute2-50a412702252ba29524b860df6c30d14f03cd34a.tar.gz |
lib: bpf_legacy: fix potential NULL-pointer dereference
If bpf_map_fetch_name() returns NULL, strlen() hits a NULL-pointer
dereference on outer_map_name.
Fix this checking outer_map_name value, and returning false when NULL,
as already done for inner_map_name before.
Fixes: 6d61a2b55799 ("lib: add libbpf support")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
-rw-r--r-- | lib/bpf_legacy.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c index e8a41e6f..91086aa2 100644 --- a/lib/bpf_legacy.c +++ b/lib/bpf_legacy.c @@ -3298,6 +3298,9 @@ bool iproute2_is_map_in_map(const char *libbpf_map_name, struct bpf_elf_map *ima *omap = ctx->maps[j]; outer_map_name = bpf_map_fetch_name(ctx, j); + if (!outer_map_name) + return false; + memcpy(omap_name, outer_map_name, strlen(outer_map_name) + 1); return true; |