[PATCH] lib: fwts_pipeio: don't report failure on freopen failure
Colin King
colin.king at canonical.com
Fri Jul 22 16:26:55 UTC 2016
From: Colin Ian King <colin.king at canonical.com>
A freopen failure on stderr means that stderr is NULL so printing
an error to that file pointer will lead to a null pointer dereference.
Silently ignore a failure.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/lib/src/fwts_pipeio.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/lib/src/fwts_pipeio.c b/src/lib/src/fwts_pipeio.c
index f62621a..68f1ff6 100644
--- a/src/lib/src/fwts_pipeio.c
+++ b/src/lib/src/fwts_pipeio.c
@@ -78,9 +78,11 @@ int fwts_pipe_open_rw(const char *command, pid_t *childpid,
goto err_close_out;
case 0:
/* Child */
- if ((fp = freopen("/dev/null", "w", stderr)) == NULL) {
- fprintf(stderr, "Cannot redirect stderr\n");
- }
+ fp = freopen("/dev/null", "w", stderr);
+ /*
+ * if null, we can't report freopen failed
+ * to stderr as it is now free
+ */
if (out_pipefds[0] != STDOUT_FILENO) {
dup2(out_pipefds[1], STDOUT_FILENO);
close(out_pipefds[1]);
--
2.8.1
More information about the fwts-devel
mailing list