From: Ben Pfaff Date: Fri, 9 Jan 2009 00:56:50 +0000 (-0800) Subject: dpctl: Exit unsuccessfully if a write to stdout or stderr failed. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3e01bdd7dc96667d96a15b992a2fdf49a6aed2d;p=openvswitch 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. --- 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); } }