From: Simson Garfinkel <simsong@acm.org>
Date: Sun, 16 Feb 2014 11:24:01 -0500
Subject: fixed handling of fputc
Forwarded: yes. merged upstream at https://github.com/simsong/tcpflow/commit/6cfe1a4905b8801084ecff00ae794388128501af

---
 src/tcpip.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/tcpip.cpp b/src/tcpip.cpp
index 603c127..ecad602 100644
--- a/src/tcpip.cpp
+++ b/src/tcpip.cpp
@@ -262,7 +262,13 @@ void tcpip::print_packet(const u_char *data, uint32_t length)
     else if(demux.opt.output_strip_nonprint){
 	for(const u_char *cc = data;cc<data+length;cc++){
 	    if(isprint(*cc) || (*cc=='\n') || (*cc=='\r')){
-		written += fputc(*cc,stdout);
+                int ret = fputc(*cc,stdout);
+                if(ret==EOF){
+                    std::cerr << "EOF on write to stdout\n";
+                    exit(1);
+                
+                }
+                written += ret;
 	    }
 	}
     }
