mirror of
https://github.com/torvalds/linux.git
synced 2026-01-12 00:42:35 +08:00
tools/bpf_jit_disasm: Fix potential negative tpath index in get_exec_path()
If readlink() fails, len will be -1, which can cause negative indexing and undefined behavior. This patch ensures that len is set to 0 on readlink failure, preventing such issues. Signed-off-by: Ruslan Semchenko <uncleruc2075@gmail.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/r/20250612131816.1870-1-uncleruc2075@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Alexei Starovoitov
parent
0e93df45c7
commit
af91af33c1
@@ -45,6 +45,8 @@ static void get_exec_path(char *tpath, size_t size)
|
||||
assert(path);
|
||||
|
||||
len = readlink(path, tpath, size);
|
||||
if (len < 0)
|
||||
len = 0;
|
||||
tpath[len] = 0;
|
||||
|
||||
free(path);
|
||||
|
||||
Reference in New Issue
Block a user