summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-08-21 15:42:58 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-08-21 15:42:58 +0000
commit82b23db3547fe38ffdbbddca8303b1ecc1dd4235 (patch)
tree8197f1c2da420d4c489d93a3702dabf3a904a5ff /main.c
parent5abba65f9f25c0bfc4b499e344b926dc3da262d0 (diff)
downloadmandoc-82b23db3547fe38ffdbbddca8303b1ecc1dd4235.tar.gz
When the stdout stream gets broken, there is no point in reading
any more input files, and it would be misleading to start a parser, because that would show randomly truncated text. Instead, print an error message and exit the program. Issue found by Leah Neukirchen <leah at vuxu dot org>, who was surprised to see half a manpage when her /tmp/ overflew.
Diffstat (limited to 'main.c')
-rw-r--r--main.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/main.c b/main.c
index e70e1a32..308f7fb5 100644
--- a/main.c
+++ b/main.c
@@ -484,6 +484,17 @@ main(int argc, char *argv[])
passthrough(resp->file, fd,
conf.output.synopsisonly);
+ if (ferror(stdout)) {
+ if (tag_files != NULL) {
+ warn("%s", tag_files->ofn);
+ tag_unlink();
+ tag_files = NULL;
+ } else
+ warn("stdout");
+ rc = MANDOCLEVEL_SYSERR;
+ break;
+ }
+
if (argc > 1 && curp.outtype <= OUTT_UTF8) {
if (curp.outdata == NULL)
outdata_alloc(&curp);