source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Do not crash on stray .Ta macros found outside column lists.
Date: Mon, 19 Nov 2012 17:30:58 -0500 (EST)	[thread overview]
Message-ID: <201211192230.qAJMUwEv011073@krisdoz.my.domain> (raw)

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

                 reply	other threads:[~2012-11-19 22:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201211192230.qAJMUwEv011073@krisdoz.my.domain \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).