diff options
author | 2015-02-10 11:02:19 +0000 | |
---|---|---|
committer | 2015-02-10 11:02:19 +0000 | |
commit | 897e9af6cad02a67323504e38d64fad925f98c44 (patch) | |
tree | 278263d795ab7573209da98f4120f2b6fb07d287 | |
parent | Remove a lie that "snmpd does not fully work yet". It works like a charm. (diff) | |
download | wireguard-openbsd-897e9af6cad02a67323504e38d64fad925f98c44.tar.xz wireguard-openbsd-897e9af6cad02a67323504e38d64fad925f98c44.zip |
Do not read past the end of the buffer if an "f" layout font modifier
is followed by the end of the input line instead of a font specifier.
Found by jsg@ with afl, test case #591.
While here, improve functionality as well:
* There is no "r" font modifier.
* Font specifiers (as opposed to font modifiers) are case sensitive.
* One-character font specifiers require trailing whitespace.
* Ignore parenthised and two-letter font specifiers.
-rw-r--r-- | regress/usr.bin/mandoc/tbl/mod/Makefile | 10 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/tbl/mod/badfont.in | 14 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/tbl/mod/badfont.out_ascii | 18 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/tbl/mod/badfont.out_lint | 2 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/tbl/mod/font.in | 6 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/tbl/mod/font.out_ascii | 2 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/tbl/mod/font.out_lint | 1 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_layout.c | 38 |
8 files changed, 72 insertions, 19 deletions
diff --git a/regress/usr.bin/mandoc/tbl/mod/Makefile b/regress/usr.bin/mandoc/tbl/mod/Makefile index 9c1bdb98484..c5bebb0ff5f 100644 --- a/regress/usr.bin/mandoc/tbl/mod/Makefile +++ b/regress/usr.bin/mandoc/tbl/mod/Makefile @@ -1,13 +1,15 @@ -# $OpenBSD: Makefile,v 1.1.1.1 2015/01/29 23:24:24 schwarze Exp $ +# $OpenBSD: Makefile,v 1.2 2015/02/10 11:02:19 schwarze Exp $ -REGRESS_TARGETS = expand font misalign +REGRESS_TARGETS = badfont expand font misalign +LINT_TARGETS = badfont font -# groff-1.22.3 defect: +# groff-1.22.3 defects: +# - The "f" font modifier swallows a following newline character. # - When space is insufficient (on either side) for properly aligning # a number, GNU tbl(1) moves the number too much to the right, # overflowing the column, even if space would be sufficient without # left padding. -SKIP_GROFF = misalign +SKIP_GROFF = badfont misalign .include <bsd.regress.mk> diff --git a/regress/usr.bin/mandoc/tbl/mod/badfont.in b/regress/usr.bin/mandoc/tbl/mod/badfont.in new file mode 100644 index 00000000000..4b765aef08c --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/mod/badfont.in @@ -0,0 +1,14 @@ +.TH TBL-MOD-BADFONT 1 "February 10, 2015" OpenBSD +.SH NAME +tbl-mod-badfont \- invalid font modifiers in table layouts +.SH DESCRIPTION +normal text +.TS +box tab(:); +lfB lf +lfI lf. +lfB lfI. +bold:none +italic:none +bold:italic +.TE diff --git a/regress/usr.bin/mandoc/tbl/mod/badfont.out_ascii b/regress/usr.bin/mandoc/tbl/mod/badfont.out_ascii new file mode 100644 index 00000000000..b0788c5040a --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/mod/badfont.out_ascii @@ -0,0 +1,18 @@ +TBL-MOD-BADFONT(1) General Commands Manual TBL-MOD-BADFONT(1) + + + +NNAAMMEE + tbl-mod-badfont - invalid font modifiers in table layouts + +DDEESSCCRRIIPPTTIIOONN + normal text + + +----------------+ + |bboolldd none | + |_i_t_a_l_i_c none | + |bboolldd _i_t_a_l_i_c | + +----------------+ + + +OpenBSD February 10, 2015 TBL-MOD-BADFONT(1) diff --git a/regress/usr.bin/mandoc/tbl/mod/badfont.out_lint b/regress/usr.bin/mandoc/tbl/mod/badfont.out_lint new file mode 100644 index 00000000000..0882648cd46 --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/mod/badfont.out_lint @@ -0,0 +1,2 @@ +mandoc: badfont.in:8:7: WARNING: unknown font, skipping request: TS f +mandoc: badfont.in:9:7: WARNING: unknown font, skipping request: TS f. diff --git a/regress/usr.bin/mandoc/tbl/mod/font.in b/regress/usr.bin/mandoc/tbl/mod/font.in index caf73e85688..b371bfcb3cc 100644 --- a/regress/usr.bin/mandoc/tbl/mod/font.in +++ b/regress/usr.bin/mandoc/tbl/mod/font.in @@ -1,12 +1,12 @@ -.TH TBL-MOD-FONT 1 2014-10-14 OpenBSD +.TH TBL-MOD-FONT 1 "February 10, 2015" OpenBSD .SH NAME tbl-mod-font \- font modifiers in table layouts .SH DESCRIPTION normal text .TS box tab(:); -cb | c | ci -cFI | c | cFB . +cb|cfCW|ci +cFI | cf(foobar) | cFB. bold:roman:italic _ italic:roman:bold diff --git a/regress/usr.bin/mandoc/tbl/mod/font.out_ascii b/regress/usr.bin/mandoc/tbl/mod/font.out_ascii index 18845607172..70438643820 100644 --- a/regress/usr.bin/mandoc/tbl/mod/font.out_ascii +++ b/regress/usr.bin/mandoc/tbl/mod/font.out_ascii @@ -16,4 +16,4 @@ DDEESSCCRRIIPPTTIIOONN +-------+-------+--------+ -OpenBSD 2014-10-14 TBL-MOD-FONT(1) +OpenBSD February 10, 2015 TBL-MOD-FONT(1) diff --git a/regress/usr.bin/mandoc/tbl/mod/font.out_lint b/regress/usr.bin/mandoc/tbl/mod/font.out_lint new file mode 100644 index 00000000000..14506a511d9 --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/mod/font.out_lint @@ -0,0 +1 @@ +mandoc: font.in:8:6: WARNING: unknown font, skipping request: TS fCW|ci diff --git a/usr.bin/mandoc/tbl_layout.c b/usr.bin/mandoc/tbl_layout.c index f50d3aeb365..7e4655479d0 100644 --- a/usr.bin/mandoc/tbl_layout.c +++ b/usr.bin/mandoc/tbl_layout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_layout.c,v 1.24 2015/01/30 04:08:37 schwarze Exp $ */ +/* $OpenBSD: tbl_layout.c,v 1.25 2015/02/10 11:02:19 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -95,12 +95,8 @@ mod: switch (tolower((unsigned char)p[(*pos)++])) { case 'b': - /* FALLTHROUGH */ - case 'i': - /* FALLTHROUGH */ - case 'r': - (*pos)--; - break; + cp->flags |= TBL_CELL_BOLD; + goto mod; case 'd': cp->flags |= TBL_CELL_BALIGN; goto mod; @@ -109,6 +105,9 @@ mod: goto mod; case 'f': break; + case 'i': + cp->flags |= TBL_CELL_ITALIC; + goto mod; case 'm': mandoc_msg(MANDOCERR_TBLLAYOUT_MOD, tbl->parse, ln, *pos, "m"); @@ -148,20 +147,37 @@ mod: goto mod; } - switch (tolower((unsigned char)p[(*pos)++])) { + /* Ignore parenthised font names for now. */ + + if (p[*pos] == '(') + goto mod; + + /* Support only one-character font-names for now. */ + + if (p[*pos] == '\0' || (p[*pos + 1] != ' ' && p[*pos + 1] != '.')) { + mandoc_vmsg(MANDOCERR_FT_BAD, tbl->parse, + ln, *pos, "TS %s", p + *pos - 1); + if (p[*pos] != '\0') + (*pos)++; + if (p[*pos] != '\0') + (*pos)++; + goto mod; + } + + switch (p[(*pos)++]) { case '3': /* FALLTHROUGH */ - case 'b': + case 'B': cp->flags |= TBL_CELL_BOLD; goto mod; case '2': /* FALLTHROUGH */ - case 'i': + case 'I': cp->flags |= TBL_CELL_ITALIC; goto mod; case '1': /* FALLTHROUGH */ - case 'r': + case 'R': goto mod; default: mandoc_vmsg(MANDOCERR_FT_BAD, tbl->parse, |