From: Andrea Claudi Date: Sat, 7 Aug 2021 16:57:38 +0000 (+0200) Subject: lib: bpf_legacy: fix potential NULL-pointer dereference X-Git-Tag: v5.14.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50a412702252ba29524b860df6c30d14f03cd34a;p=thirdparty%2Fiproute2.git 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 Signed-off-by: Stephen Hemminger --- diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c index e8a41e6fb..91086aa20 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;