]> git.baikalelectronics.ru Git - kernel.git/commit
samples, bpf: fix to change the buffer size for read()
authorChang-Hsien Tsai <luke.tw@gmail.com>
Sun, 19 May 2019 09:05:44 +0000 (09:05 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 21 May 2019 14:36:48 +0000 (16:36 +0200)
commitc54a572dcf17769a68a1676c103edcad85d68cfd
tree9daa3a8015f051b4fc36020d310b266f652627e5
parent212f702a0b0a50624f81b7c850e5ba29594a65b5
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>
samples/bpf/bpf_load.c