From a3e01bdd7dc96667d96a15b992a2fdf49a6aed2d Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 8 Jan 2009 16:56:50 -0800 Subject: [PATCH] dpctl: Exit unsuccessfully if a write to stdout or stderr failed. A program should exit with an error if its output failed, so check for this before termination. Found by Chris Eagle via Fortify. --- utilities/dpctl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utilities/dpctl.c b/utilities/dpctl.c index c6de5a1e..0113d967 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -123,6 +123,12 @@ int main(int argc, char *argv[]) p->name, p->max_args); else { p->handler(&s, argc, argv); + if (ferror(stdout)) { + ofp_fatal(0, "write to stdout failed"); + } + if (ferror(stderr)) { + ofp_fatal(0, "write to stderr failed"); + } exit(0); } } -- 2.30.2