From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id qAJMUw5t030408 for ; Mon, 19 Nov 2012 17:30:58 -0500 (EST) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id qAJMUwEv011073; Mon, 19 Nov 2012 17:30:58 -0500 (EST) Date: Mon, 19 Nov 2012 17:30:58 -0500 (EST) Message-Id: <201211192230.qAJMUwEv011073@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Do not crash on stray .Ta macros found outside column lists. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Do not crash on stray .Ta macros found outside column lists. Problem reported by jmc@, thanks. Modified Files: -------------- mdocml: TODO mandoc.h mdoc_macro.c read.c Revision Data ------------- Index: TODO =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/TODO,v retrieving revision 1.147 retrieving revision 1.148 diff -LTODO -LTODO -u -p -r1.147 -r1.148 --- TODO +++ TODO @@ -7,11 +7,7 @@ * crashes ************************************************************************ -- $ echo ".Ta" >> ls.1 - $ mandoc ls.1 - assertion "MDOC_BLOCK == p->parent->type" failed: - file "/usr/src/usr.bin/mandoc/mdoc.c", line 399, function "node_append" - from jmc@ Thu, 20 Sep 2012 21:35:58 +0059 +None known right now. ************************************************************************ * missing features Index: mdoc_macro.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_macro.c,v retrieving revision 1.120 retrieving revision 1.121 diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.120 -r1.121 --- mdoc_macro.c +++ mdoc_macro.c @@ -1759,16 +1759,22 @@ phrase(struct mdoc *mdoc, int line, int 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)) Index: mandoc.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v retrieving revision 1.105 retrieving revision 1.106 diff -Lmandoc.h -Lmandoc.h -u -p -r1.105 -r1.106 --- mandoc.h +++ mandoc.h @@ -1,6 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons + * Copyright (c) 2012 Ingo Schwarze * * 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 */ Index: read.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v retrieving revision 1.33 retrieving revision 1.34 diff -Lread.c -Lread.c -u -p -r1.33 -r1.34 --- read.c +++ read.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010, 2011 Ingo Schwarze + * Copyright (c) 2010, 2011, 2012 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -180,6 +180,7 @@ static const char * const mandocerrs[MAN "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", -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv