]> granicus.if.org Git - strace/commitdiff
2003-11-06 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Thu, 6 Nov 2003 23:41:22 +0000 (23:41 +0000)
committerRoland McGrath <roland@redhat.com>
Thu, 6 Nov 2003 23:41:22 +0000 (23:41 +0000)
* strace.c (tprintf): Check result of vfprintf and use perror when it
fails while not writing to stderr itself.  Fixes Debian bug #218762.

strace.c

index 13b42d4d80c5c5902dabd93ae140718186102078..02d1e6e8b9cca7d3d85a70af5864dd111fb2402f 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -2213,8 +2213,14 @@ va_dcl
        va_list args;
 
        VA_START(args, fmt);
-       if (outf)
-               curcol += vfprintf(outf, fmt, args);
+       if (outf) {
+               int n = vfprintf(outf, fmt, args);
+               if (n < 0 && outf != stderr)
+                       perror(outfname == NULL
+                              ? "<writing to pipe>" : outfname);
+               else
+                       curcol += n;
+       }
        va_end(args);
        return;
 }