Blame SOURCES/0114-lib-bpf-Check-return-value-of-write.patch

99be8f
From 78f4b87c3f014e378377d3ecc55d1ec46cd57b51 Mon Sep 17 00:00:00 2001
99be8f
From: Andrea Claudi <aclaudi@redhat.com>
99be8f
Date: Mon, 29 Apr 2019 20:08:08 +0200
99be8f
Subject: [PATCH] lib/bpf: Check return value of write()
99be8f
99be8f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
99be8f
Upstream Status: iproute2.git commit b5c78e1b2c868
99be8f
99be8f
commit b5c78e1b2c8681e82684f47563acd3d383893658
99be8f
Author: Phil Sutter <phil@nwl.cc>
99be8f
Date:   Thu Aug 24 11:41:29 2017 +0200
99be8f
99be8f
    lib/bpf: Check return value of write()
99be8f
99be8f
    This is merely to silence the compiler warning. If write to stderr
99be8f
    failed, assume that printing an error message will fail as well so don't
99be8f
    even try.
99be8f
99be8f
    Signed-off-by: Phil Sutter <phil@nwl.cc>
99be8f
---
99be8f
 lib/bpf.c | 3 ++-
99be8f
 1 file changed, 2 insertions(+), 1 deletion(-)
99be8f
99be8f
diff --git a/lib/bpf.c b/lib/bpf.c
99be8f
index 33c5288e82187..7eb754ad7cb56 100644
99be8f
--- a/lib/bpf.c
99be8f
+++ b/lib/bpf.c
99be8f
@@ -486,7 +486,8 @@ int bpf_trace_pipe(void)
99be8f
 
99be8f
 		ret = read(fd, buff, sizeof(buff) - 1);
99be8f
 		if (ret > 0) {
99be8f
-			write(2, buff, ret);
99be8f
+			if (write(STDERR_FILENO, buff, ret) != ret)
99be8f
+				return -1;
99be8f
 			fflush(stderr);
99be8f
 		}
99be8f
 	}
99be8f
-- 
d30c09
2.21.0
99be8f