Re: [PATCH] samples: bpf: fix: change the buffer size for read()

2019-05-21 Thread luke
On Tue, May 21, 2019 at 11:05 PM David Laight wrote: > > From: Chang-Hsien Tsai > > @@ -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_f

RE: [PATCH] samples: bpf: fix: change the buffer size for read()

2019-05-21 Thread David Laight
From: Chang-Hsien Tsai > Sent: 19 May 2019 10:06 > 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) { >

Re: [PATCH] samples: bpf: fix: change the buffer size for read()

2019-05-21 Thread Daniel Borkmann
On 05/19/2019 11:05 AM, Chang-Hsien Tsai wrote: > 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) { >

[PATCH] samples: bpf: fix: change the buffer size for read()

2019-05-19 Thread Chang-Hsien Tsai
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 T