source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: After .ti, there are many reasons why the offset may change, so
@ 2020-09-06 14:45 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2020-09-06 14:45 UTC (permalink / raw)
  To: source

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 <jes at posteo dot de>.

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 <kristaps@bsd.lv>
- * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014,2015,2017,2018,2020 Ingo Schwarze <schwarze@openbsd.org>
  *
  * 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 <kristaps@bsd.lv>
- * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014,2015,2016,2017,2020 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2017 Marc Espie <espie@openbsd.org>
  *
  * 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-06 14:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-06 14:45 mandoc: After .ti, there are many reasons why the offset may change, so schwarze

source@mandoc.bsd.lv

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/mandoc-source

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 mandoc-source mandoc-source/ http://inbox.vuxu.org/mandoc-source \
		source@mandoc.bsd.lv
	public-inbox-index mandoc-source

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.source


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git