diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-08-21 15:42:58 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-08-21 15:42:58 +0000 |
commit | 3710e49fec4d10ef6acfb714eabf077a7aaa3ce4 (patch) | |
tree | cf937ada8dc7babca0b24a0985053b5fa7c435e1 /main.c | |
parent | dc43a8e1c289a4a212ae1fbc154869d416d4b81b (diff) | |
download | mandoc-3710e49fec4d10ef6acfb714eabf077a7aaa3ce4.tar.gz mandoc-3710e49fec4d10ef6acfb714eabf077a7aaa3ce4.tar.zst mandoc-3710e49fec4d10ef6acfb714eabf077a7aaa3ce4.zip |
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.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.301 2017/07/26 10:21:55 schwarze Exp $ */ +/* $Id: main.c,v 1.302 2017/08/21 15:42:58 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -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); |