]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
lib: bpf_legacy: fix potential NULL-pointer dereference
authorAndrea Claudi <aclaudi@redhat.com>
Sat, 7 Aug 2021 16:57:38 +0000 (18:57 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 11 Aug 2021 02:55:12 +0000 (19:55 -0700)
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>
lib/bpf_legacy.c

index e8a41e6fbd17d42b73874b19504ff794ff0ad241..91086aa204536c1d0236f9d8419a06db15b26fbd 100644 (file)
@@ -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;