[prev in list] [next in list] [prev in thread] [next in thread]
List: mandoc-source
Subject: mdocml: Do not crash on stray .Ta macros found outside column lists.
From: schwarze () mdocml ! bsd ! lv
Date: 2012-11-19 22:30:58
Message-ID: 201211192230.qAJMUwEv011073 () krisdoz ! my ! domain
[Download RAW message or body]
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 <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 */
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 <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
@@ -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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic