diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2012-11-19 22:28:36 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2012-11-19 22:28:36 +0000 |
commit | f6aefaa94996adb3a94cf829d7d536f2457f186f (patch) | |
tree | 7e9d0f5a59bcbb947052eb699b49cf422ce4233b /usr.bin | |
parent | 714b5995a4bacf5d3b4f69e18b24f338eb290330 (diff) |
Do not crash on stray .Ta macros found outside column lists.
Problem reported by jmc@, thanks.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 16 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 5 |
3 files changed, 17 insertions, 8 deletions
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index 14f32bf00cc..e10d6390d82 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,6 +1,7 @@ -/* $Id: mandoc.h,v 1.49 2012/11/16 22:20:40 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.50 2012/11/19 22:28:35 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> + * Copyright (c) 2012 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 @@ -135,6 +136,7 @@ enum mandocerr { MANDOCERR_MACRO, /* skipping unknown macro */ MANDOCERR_REQUEST, /* NOT IMPLEMENTED: skipping request */ MANDOCERR_ARGCOUNT, /* argument count wrong */ + MANDOCERR_STRAYTA, /* skipping column outside column list */ MANDOCERR_NOSCOPE, /* skipping end of block that is not open */ MANDOCERR_SCOPEBROKEN, /* missing end of block */ MANDOCERR_SCOPEEXIT, /* scope open on exit */ 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)) diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 2150a5550bd..59692abf743 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,7 +1,7 @@ -/* $Id: read.c,v 1.11 2012/11/16 22:20:40 schwarze Exp $ */ +/* $Id: read.c,v 1.12 2012/11/19 22:28:35 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010, 2011, 2012 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 @@ -169,6 +169,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "skipping unknown macro", "NOT IMPLEMENTED, please use groff: skipping request", "argument count wrong", + "skipping column outside column list", "skipping end of block that is not open", "missing end of block", "scope open on exit", |