]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
lib/bpf: Check return value of write()
authorPhil Sutter <phil@nwl.cc>
Thu, 24 Aug 2017 09:41:29 +0000 (11:41 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 24 Aug 2017 22:22:10 +0000 (15:22 -0700)
This is merely to silence the compiler warning. If write to stderr
failed, assume that printing an error message will fail as well so don't
even try.

Signed-off-by: Phil Sutter <phil@nwl.cc>
lib/bpf.c

index 09551990dd707b9526776b8ab5447b799ba92022..0bd0a95eafe6cbc6309784c61a796f82c3869be7 100644 (file)
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -591,7 +591,8 @@ int bpf_trace_pipe(void)
 
                ret = read(fd, buff, sizeof(buff) - 1);
                if (ret > 0) {
-                       write(2, buff, ret);
+                       if (write(STDERR_FILENO, buff, ret) != ret)
+                               return -1;
                        fflush(stderr);
                }
        }