mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
samples, bpf: fix to change the buffer size for read()
If the trace for read is larger than 4096, the return value sz will be 4096. This results in off-by-one error on buf: static char buf[4096]; ssize_t sz; sz = read(trace_fd, buf, sizeof(buf)); if (sz > 0) { buf[sz] = 0; puts(buf); } Signed-off-by: Chang-Hsien Tsai <luke.tw@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
f7355a6c04
commit
f7c2d64bac
1 changed files with 1 additions and 1 deletions
|
@ -678,7 +678,7 @@ void read_trace_pipe(void)
|
|||
static char buf[4096];
|
||||
ssize_t sz;
|
||||
|
||||
sz = read(trace_fd, buf, sizeof(buf));
|
||||
sz = read(trace_fd, buf, sizeof(buf) - 1);
|
||||
if (sz > 0) {
|
||||
buf[sz] = 0;
|
||||
puts(buf);
|
||||
|
|
Loading…
Reference in a new issue