mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 05:12:49 +00:00
libbpf: fix an snprintf() overflow check
[ Upstream commitb77ffb30cf
] The snprintf() function returns the number of bytes it *would* have copied if there were enough space. So it can return > the sizeof(gen->attach_target). Fixes:6723474373
("libbpf: Generate loader program out of BPF ELF file.") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/r/YtZ+oAySqIhFl6/J@kili Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
4a5ae176fd
commit
d43f85d3d0
1 changed files with 1 additions and 1 deletions
|
@ -533,7 +533,7 @@ void bpf_gen__record_attach_target(struct bpf_gen *gen, const char *attach_name,
|
|||
gen->attach_kind = kind;
|
||||
ret = snprintf(gen->attach_target, sizeof(gen->attach_target), "%s%s",
|
||||
prefix, attach_name);
|
||||
if (ret == sizeof(gen->attach_target))
|
||||
if (ret >= sizeof(gen->attach_target))
|
||||
gen->error = -ENOSPC;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue