From: Phil Sutter Date: Thu, 24 Aug 2017 09:41:29 +0000 (+0200) Subject: lib/bpf: Check return value of write() X-Git-Tag: v4.13.0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5c78e1b2c8681e82684f47563acd3d383893658;p=thirdparty%2Fiproute2.git lib/bpf: Check return value of write() 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 --- diff --git a/lib/bpf.c b/lib/bpf.c index 09551990d..0bd0a95ea 100644 --- 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); } }