From ad8c4c52cb0a5e6b0ea8eb819cc08813ef58f957 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 1 Sep 2020 18:24:11 +0000 Subject: Ignore unreasonably large spacing modifiers in tbl layouts. Jan Schreiber ran afl on mandoc and it turned out mandoc tried to use spacing modifiers so large that they would trigger assertion failures in term_ascii.c, function locale_advance(). --- regress/usr.bin/mandoc/tbl/layout/Makefile | 12 +++--- .../usr.bin/mandoc/tbl/layout/spacing-nogroff.in | 13 +++++++ .../mandoc/tbl/layout/spacing-nogroff.out_ascii | 18 +++++++++ .../mandoc/tbl/layout/spacing-nogroff.out_lint | 1 + regress/usr.bin/mandoc/tbl/layout/spacing.in | 43 ++++++++++++++++++++++ .../usr.bin/mandoc/tbl/layout/spacing.out_ascii | 39 ++++++++++++++++++++ 6 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.in create mode 100644 regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.out_ascii create mode 100644 regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.out_lint create mode 100644 regress/usr.bin/mandoc/tbl/layout/spacing.in create mode 100644 regress/usr.bin/mandoc/tbl/layout/spacing.out_ascii (limited to 'regress') diff --git a/regress/usr.bin/mandoc/tbl/layout/Makefile b/regress/usr.bin/mandoc/tbl/layout/Makefile index 2cff58512fb..b49c49848ac 100644 --- a/regress/usr.bin/mandoc/tbl/layout/Makefile +++ b/regress/usr.bin/mandoc/tbl/layout/Makefile @@ -1,15 +1,17 @@ -# $OpenBSD: Makefile,v 1.6 2020/01/11 20:56:26 schwarze Exp $ +# $OpenBSD: Makefile,v 1.7 2020/09/01 18:24:10 schwarze Exp $ REGRESS_TARGETS = badspan center complex empty emptycol emptyline -REGRESS_TARGETS += lines lines-nogroff numbers shortlines span -LINT_TARGETS = badspan complex empty +REGRESS_TARGETS += lines lines-nogroff numbers +REGRESS_TARGETS += shortlines spacing spacing-nogroff span +LINT_TARGETS = badspan complex empty spacing-nogroff -# groff-1.22.3 defects: +# groff-1.22.4 defects: # - When the layout is completely empty, # GNU eqn produces no output whatsoever for the whole table. # - When there is no horizontal line at the top, # vertical lines extend beyond the top of the table. +# - Excessive spacing modifiers in the layout are honoured. -SKIP_GROFF = empty lines-nogroff +SKIP_GROFF = empty lines-nogroff spacing-nogroff .include diff --git a/regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.in b/regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.in new file mode 100644 index 00000000000..ed7c55eb17e --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.in @@ -0,0 +1,13 @@ +.\" $OpenBSD: spacing-nogroff.in,v 1.1 2020/09/01 18:24:10 schwarze Exp $ +.TH TBL-LAYOUT-SPACING 1 "September 1, 2020" +.SH NAME +tbl-layout-spacing-nogroff \- excessive spacing modifier +.SH DESCRIPTION +initial text +.TS +box tab(:); +R 10 L. +a:b +.TE +.sp +final text diff --git a/regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.out_ascii b/regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.out_ascii new file mode 100644 index 00000000000..f4d68e74ba3 --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.out_ascii @@ -0,0 +1,18 @@ +TBL-LAYOUT-SPACING(1) General Commands Manual TBL-LAYOUT-SPACING(1) + + + +NNAAMMEE + tbl-layout-spacing-nogroff - excessive spacing modifier + +DDEESSCCRRIIPPTTIIOONN + initial text + + +------+ + |a b | + +------+ + final text + + + +OpenBSD September 1, 2020 TBL-LAYOUT-SPACING(1) diff --git a/regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.out_lint b/regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.out_lint new file mode 100644 index 00000000000..6f659c218d3 --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/layout/spacing-nogroff.out_lint @@ -0,0 +1 @@ +mandoc: spacing-nogroff.in:9:3: ERROR: ignoring excessive spacing in tbl layout: 10 diff --git a/regress/usr.bin/mandoc/tbl/layout/spacing.in b/regress/usr.bin/mandoc/tbl/layout/spacing.in new file mode 100644 index 00000000000..c1190b24fb0 --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/layout/spacing.in @@ -0,0 +1,43 @@ +.\" $OpenBSD: spacing.in,v 1.1 2020/09/01 18:24:10 schwarze Exp $ +.TH TBL-LAYOUT-SPACING 1 "September 1, 2020" +.SH NAME +tbl-layout-spacing \- spacing modifiers +.SH DESCRIPTION +default spacing: +.TS +box tab(:); +R L. +a:b +.TE +.sp +spacing 0: +.TS +box tab(:); +R 0 L. +a:b +.TE +.sp +spacing 1: +.TS +box tab(:); +R 1 L. +a:b +.TE +.sp +spacing 2: +.TS +allbox tab(:); +R 2 L. +a:b +.TE +.sp +spacing 5: +.TS +allbox tab(:); +R 5|| L. +a:b +.TE +.sp +leaked tab settings: +.br +a b c d e f diff --git a/regress/usr.bin/mandoc/tbl/layout/spacing.out_ascii b/regress/usr.bin/mandoc/tbl/layout/spacing.out_ascii new file mode 100644 index 00000000000..3d51d7d52a8 --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/layout/spacing.out_ascii @@ -0,0 +1,39 @@ +TBL-LAYOUT-SPACING(1) General Commands Manual TBL-LAYOUT-SPACING(1) + + + +NNAAMMEE + tbl-layout-spacing - spacing modifiers + +DDEESSCCRRIIPPTTIIOONN + default spacing: + + +------+ + |a b | + +------+ + spacing 0: + + +---+ + |ab | + +---+ + spacing 1: + + +----+ + |a b | + +----+ + spacing 2: + + +--+--+ + |a |b | + +--+--+ + spacing 5: + + +---++---+ + |a || b | + +---++---+ + leaked tab settings: + a b cdef + + + +OpenBSD September 1, 2020 TBL-LAYOUT-SPACING(1) -- cgit v1.2.3