Message ID | 4dda3f4c193e1da7ac77ee50860111243cd63065.1628352013.git.aclaudi@redhat.com |
---|---|
State | New |
Headers | show |
Series | [iproute2] lib: bpf_legacy: fix potential NULL-pointer dereference | expand |
diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c index d57d2635..372bcecc 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;
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> --- lib/bpf_legacy.c | 3 +++ 1 file changed, 3 insertions(+)