aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-06-11 16:04:36 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-06-11 16:04:36 +0000
commit304ecda43472e85a726c792ca5c88b3f2655a892 (patch)
tree44de9f1d4e52a6c0f44067790c8343f7df46be19
parentdfcfddad25114d69f0ea23cc3caf55ef9e7ce6e7 (diff)
downloadmandoc-304ecda43472e85a726c792ca5c88b3f2655a892.tar.gz
mandoc-304ecda43472e85a726c792ca5c88b3f2655a892.tar.zst
mandoc-304ecda43472e85a726c792ca5c88b3f2655a892.zip
Do not access a NULL pointer if a table contains a horizontal line
next to a table line having fewer columns than the table as a whole. Bug found by Stephen Gregoratto <dev at sgregoratto dot me> with aerc-config(5).
-rw-r--r--TODO5
-rw-r--r--regress/tbl/layout/Makefile4
-rw-r--r--regress/tbl/layout/shortlines.in49
-rw-r--r--regress/tbl/layout/shortlines.out_ascii48
-rw-r--r--tbl_term.c16
5 files changed, 114 insertions, 8 deletions
diff --git a/TODO b/TODO
index dd97163c..049e6a4f 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
************************************************************************
* Official mandoc TODO.
-* $Id: TODO,v 1.294 2019/05/03 17:31:15 schwarze Exp $
+* $Id: TODO,v 1.295 2019/06/11 16:04:36 schwarze Exp $
************************************************************************
Many issues are annotated for difficulty as follows:
@@ -285,6 +285,9 @@ are mere guesses, and some may be wrong.
https://github.com/schmonz/ikiwiki/compare/mandoc
Amitai Schlair Mon, 19 May 2014 14:05:53 -0400
+- check compatibility with
+ https://git.sr.ht/~sircmpwn/scdoc
+
- check features of the Slackware man.conf(5) format
Carsten Kunze Wed, 11 Mar 2015 17:57:24 +0100
diff --git a/regress/tbl/layout/Makefile b/regress/tbl/layout/Makefile
index 9cc65754..a56cbc2f 100644
--- a/regress/tbl/layout/Makefile
+++ b/regress/tbl/layout/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.2 2015/01/30 00:27:09 schwarze Exp $
+# $OpenBSD: Makefile,v 1.4 2019/06/11 15:40:41 schwarze Exp $
REGRESS_TARGETS = center complex empty emptyline
-REGRESS_TARGETS += lines lines-nogroff numbers span
+REGRESS_TARGETS += lines lines-nogroff numbers shortlines span
LINT_TARGETS = complex empty
# groff-1.22.3 defects:
diff --git a/regress/tbl/layout/shortlines.in b/regress/tbl/layout/shortlines.in
new file mode 100644
index 00000000..f6434619
--- /dev/null
+++ b/regress/tbl/layout/shortlines.in
@@ -0,0 +1,49 @@
+.\" $OpenBSD: shortlines.in,v 1.1 2019/06/11 15:40:41 schwarze Exp $
+.TH TBL-LAYOUT-SHORTLINES 1 "June 11, 2019"
+.SH NAME
+tbl-layout-shortlines \- table lines of different length
+.SH DESCRIPTION
+normal text
+.TS
+allbox tab(:);
+L L
+L
+L L.
+left:right
+short
+left:right
+.TE
+.sp
+.TS
+allbox tab(:);
+L L
+L
+L
+L L.
+left:right
+first short
+second short
+left:right
+.TE
+.sp
+.TS
+allbox tab(:);
+L L L
+L L
+L.
+left:middle:right
+short:line
+very short
+.TE
+.sp
+.TS
+allbox tab(:);
+L
+L L
+L L L.
+very short
+short:line
+left:middle:right
+.TE
+
+
diff --git a/regress/tbl/layout/shortlines.out_ascii b/regress/tbl/layout/shortlines.out_ascii
new file mode 100644
index 00000000..02fe01d7
--- /dev/null
+++ b/regress/tbl/layout/shortlines.out_ascii
@@ -0,0 +1,48 @@
+TBL-LAYOUT-SHORTLINES(1) General Commands Manual TBL-LAYOUT-SHORTLINES(1)
+
+
+
+NNAAMMEE
+ tbl-layout-shortlines - table lines of different length
+
+DDEESSCCRRIIPPTTIIOONN
+ normal text
+
+ +------+-------+
+ |left | right |
+ +------+-------+
+ |short | |
+ +------+-------+
+ |left | right |
+ +------+-------+
+
+ +-------------+-------+
+ |left | right |
+ +-------------+-------+
+ |first short | |
+ +-------------+-------+
+ |second short | |
+ +-------------+-------+
+ |left | right |
+ +-------------+-------+
+
+ +-----------+--------+-------+
+ |left | middle | right |
+ +-----------+--------+-------+
+ |short | line | |
+ +-----------+--------+-------+
+ |very short | | |
+ +-----------+--------+-------+
+
+ +-----------+--------+-------+
+ |very short | | |
+ +-----------+--------+-------+
+ |short | line | |
+ +-----------+--------+-------+
+ |left | middle | right |
+ +-----------+--------+-------+
+
+
+
+
+OpenBSD June 11, 2019 TBL-LAYOUT-SHORTLINES(1)
diff --git a/tbl_term.c b/tbl_term.c
index 380877bd..4a4161cf 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_term.c,v 1.70 2019/03/18 08:00:34 schwarze Exp $ */
+/* $Id: tbl_term.c,v 1.71 2019/06/11 16:04:36 schwarze Exp $ */
/*
* Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -622,8 +622,12 @@ tbl_hrule(struct termp *tp, const struct tbl_span *spp,
(spp == NULL || cpn == NULL ||
cpn->pos != TBL_CELL_DOWN ? BRIGHT * hw : 0), 1);
+ col = tp->tbl.cols;
for (;;) {
- col = tp->tbl.cols + cp->col;
+ if (cp == NULL)
+ col++;
+ else
+ col = tp->tbl.cols + cp->col;
/* Print the horizontal line inside this column. */
@@ -649,7 +653,8 @@ tbl_hrule(struct termp *tp, const struct tbl_span *spp,
uw = 1;
}
cpp = cpp->next;
- }
+ } else if (spp != NULL && opts & TBL_OPT_ALLBOX)
+ uw = 1;
if (cp != NULL)
cp = cp->next;
if (cpn != NULL) {
@@ -661,8 +666,9 @@ tbl_hrule(struct termp *tp, const struct tbl_span *spp,
cpn = cpn->next;
while (dpn != NULL && dpn->layout != cpn)
dpn = dpn->next;
- }
- if (cpp == NULL && cp == NULL && cpn == NULL)
+ } else if (spn != NULL && opts & TBL_OPT_ALLBOX)
+ dw = 1;
+ if (col + 1 == tp->tbl.cols + sp->opts->cols)
break;
/* Vertical lines do not cross spanned cells. */