From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6316 invoked from network); 6 Sep 2020 14:45:56 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 6 Sep 2020 14:45:56 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id d84cdc34 for ; Sun, 6 Sep 2020 09:45:52 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id b1405267 for ; Sun, 6 Sep 2020 09:45:52 -0500 (EST) Date: Sun, 6 Sep 2020 09:45:52 -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: After .ti, there are many reasons why the offset may change, so X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- After .ti, there are many reasons why the offset may change, so setting it back later requires a guard against underflow, or subsequent assertions may fail. Issue found in an afl run performed by Jan Schreiber . Modified Files: -------------- mandoc: term_ascii.c term_ps.c Revision Data ------------- Index: term_ascii.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/term_ascii.c,v retrieving revision 1.64 retrieving revision 1.65 diff -Lterm_ascii.c -Lterm_ascii.c -u -p -r1.64 -r1.65 --- term_ascii.c +++ term_ascii.c @@ -1,7 +1,7 @@ -/* $Id$ */ +/* $Id$ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze + * Copyright (c) 2014,2015,2017,2018,2020 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -232,7 +232,10 @@ ascii_endline(struct termp *p) { p->line++; - p->tcol->offset -= p->ti; + if ((int)p->tcol->offset > p->ti) + p->tcol->offset -= p->ti; + else + p->tcol->offset = 0; p->ti = 0; putchar('\n'); } @@ -390,7 +393,10 @@ locale_endline(struct termp *p) { p->line++; - p->tcol->offset -= p->ti; + if ((int)p->tcol->offset > p->ti) + p->tcol->offset -= p->ti; + else + p->tcol->offset = 0; p->ti = 0; putwchar(L'\n'); } Index: term_ps.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/term_ps.c,v retrieving revision 1.91 retrieving revision 1.92 diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.91 -r1.92 --- term_ps.c +++ term_ps.c @@ -1,7 +1,7 @@ -/* $Id$ */ +/* $Id$ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze + * Copyright (c) 2014,2015,2016,2017,2020 Ingo Schwarze * Copyright (c) 2017 Marc Espie * * Permission to use, copy, modify, and distribute this software for any @@ -1252,7 +1252,10 @@ ps_endline(struct termp *p) ps_closepage(p); - p->tcol->offset -= p->ti; + if ((int)p->tcol->offset > p->ti) + p->tcol->offset -= p->ti; + else + p->tcol->offset = 0; p->ti = 0; } -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv