Commit ae3646e
tools/bpf/bpftool: fix buffer handling in get_fd_type()
The current check "if (n == sizeof(buf))" is incorrect for detecting
buffer overflow from readlink(). When readlink() fills the entire
buffer, it returns sizeof(buf) but does not null-terminate the string,
leading to potential buffer overrun in subsequent string operations.
Fix by changing the condition to "n >= sizeof(buf)" to properly detect
when the buffer is completely filled, ensuring space is reserved for
null termination.
Signed-off-by: Kaushlendra Kumar <[email protected]>1 parent c979e9f commit ae3646e
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
| 469 | + | |
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
| |||
0 commit comments