]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Fix the error handling in 'ndo_printf' function
authorFrancois-Xavier Le Bail <[email protected]>
Mon, 12 Oct 2015 20:17:01 +0000 (22:17 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Mon, 12 Oct 2015 20:30:31 +0000 (22:30 +0200)
Moreover:
Replace strerror() calls with pcap_strerror() calls, in case some platform
lacks strerror().

print.c
tcpdump.c

diff --git a/print.c b/print.c
index ee8ee97b28d9fbe77c33f2876e7935ef1d6a689c..9fedd9fba2b0e19b054413ee021c510eb2a859b7 100644 (file)
--- a/print.c
+++ b/print.c
@@ -462,6 +462,8 @@ ndo_printf(netdissect_options *ndo _U_, const char *fmt, ...)
        ret = vfprintf(stdout, fmt, args);
        va_end(args);
 
+       if (ret < 0)
+               ndo_error(ndo, "Unable to write output: %s", pcap_strerror(errno));
        return (ret);
 }
 
index de0054ec29bb9c9741abfe32a861ceff6b2aac29..3fe1484480764c2649c2328501ebdcdb1ea242d1 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1247,7 +1247,7 @@ main(int argc, char **argv)
                                VFile = fopen(VFileName, "r");
 
                        if (VFile == NULL)
-                               error("Unable to open file: %s\n", strerror(errno));
+                               error("Unable to open file: %s\n", pcap_strerror(errno));
 
                        ret = get_next_file(VFile, VFileLine);
                        if (!ret)
@@ -1906,7 +1906,7 @@ compress_savefile(const char *filename)
                        "compress_savefile:execlp(%s, %s): %s\n",
                        zflag,
                        filename,
-                       strerror(errno));
+                       pcap_strerror(errno));
 # ifdef HAVE_FORK
        exit(1);
 # else