diff options
author | 2012-11-19 22:28:35 +0000 | |
---|---|---|
committer | 2012-11-19 22:28:35 +0000 | |
commit | 2a131ac556d2b2a89f577c2feeba2958b3e94e47 (patch) | |
tree | e2ddbac392d88e07f990857778e2ec489490e921 /usr.bin/mandoc/mdoc_macro.c | |
parent | Make sure to invoke end_sequence() before passing it to any emit_insn() (diff) | |
download | wireguard-openbsd-2a131ac556d2b2a89f577c2feeba2958b3e94e47.tar.xz wireguard-openbsd-2a131ac556d2b2a89f577c2feeba2958b3e94e47.zip |
Do not crash on stray .Ta macros found outside column lists.
Problem reported by jmc@, thanks.
Diffstat (limited to 'usr.bin/mandoc/mdoc_macro.c')
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index 8093a52a50a..b869c6fa3fe 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.77 2012/11/18 00:05:28 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.78 2012/11/19 22:28:35 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -1755,16 +1755,22 @@ phrase(struct mdoc *mdoc, int line, int ppos, char *buf) static int phrase_ta(MACRO_PROT_ARGS) { + struct mdoc_node *n; int la; enum mdoct ntok; enum margserr ac; char *p; - /* - * FIXME: this is overly restrictive: if the `Ta' is unexpected, - * it should simply error out with ARGSLOST. - */ + /* Make sure we are in a column list or ignore this macro. */ + n = mdoc->last; + while (NULL != n && MDOC_Bl != n->tok) + n = n->parent; + if (NULL == n || LIST_column != n->norm->Bl.type) { + mdoc_pmsg(mdoc, line, ppos, MANDOCERR_STRAYTA); + return(1); + } + /* Advance to the next column. */ if ( ! rew_sub(MDOC_BODY, mdoc, MDOC_It, line, ppos)) return(0); if ( ! mdoc_body_alloc(mdoc, line, ppos, MDOC_It)) |