From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 95c232a8 for ; Tue, 19 Mar 2019 11:26:38 -0500 (EST) Date: Tue, 19 Mar 2019 11:26:38 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: When the last line of the input is empty and the previous line X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- When the last line of the input is empty and the previous line reduced the line input buffer to a length of one byte, do not write one byte past the end of the line input buffer. Minimal code to show the bug: printf ".ds X\n.X\n\n" | MALLOC_OPTIONS=C mandoc Bug found by bentley@ in the sysutils/rancid par(1) manual page. Modified Files: -------------- mandoc: read.c Revision Data ------------- Index: read.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/read.c,v retrieving revision 1.211 retrieving revision 1.212 diff -Lread.c -Lread.c -u -p -r1.211 -r1.212 --- read.c +++ read.c @@ -255,6 +255,8 @@ mparse_buf_r(struct mparse *curp, struct /* XXX Ugly hack to mark the end of the input. */ if (i == blk.sz || blk.buf[i] == '\0') { + if (pos + 2 > ln.sz) + resize_buf(&ln, 256); ln.buf[pos++] = '\n'; ln.buf[pos] = '\0'; } -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv