source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Using macros in .Sh header lines, or having .Sm off or .Bk
Date: Mon, 14 Apr 2014 20:41:10 -0400 (EDT)	[thread overview]
Message-ID: <201404150041.s3F0fAJ7026138@krisdoz.my.domain> (raw)

Log Message:
-----------
Using macros in .Sh header lines, or having .Sm off or .Bk -words open
while processing .Sh, is not at all recommended, but it's not strictly
a syntax violation either, and in any case, mandoc must not die in an
assertion.  I broke this in rev. 1.124.

Crash found while trying to read the (rather broken) original 4.3BSD-Reno
od(1) manual page.

Modified Files:
--------------
    mdocml:
        mdoc_validate.c

Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.208
retrieving revision 1.209
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.208 -r1.209
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -1950,7 +1950,7 @@ static int
 post_sh_head(POST_ARGS)
 {
 	struct mdoc_node *n;
-	const char	*secname;
+	char		*secname;
 	enum mdoc_sec	 sec;
 
 	/*
@@ -1962,15 +1962,8 @@ post_sh_head(POST_ARGS)
 
 	secname = NULL;
 	sec = SEC_CUSTOM;
-	n = mdoc->last;
-	if (n->child) {
-		assert(1 == n->nchild);
-		n = n->child;
-		assert(NULL != n);
-		assert(MDOC_TEXT == n->type);
-		secname = n->string;
-		sec = a2sec(secname);
-	}
+	mdoc_deroff(&secname, mdoc->last);
+	sec = NULL == secname ? SEC_CUSTOM : a2sec(secname);
 
 	/* The NAME should be first. */
 
@@ -2007,8 +2000,10 @@ post_sh_head(POST_ARGS)
 
 	/* We don't care about custom sections after this. */
 
-	if (SEC_CUSTOM == sec)
+	if (SEC_CUSTOM == sec) {
+		free(secname);
 		return(1);
+	}
 
 	/*
 	 * Check whether our non-custom section is being repeated or is
@@ -2052,6 +2047,7 @@ post_sh_head(POST_ARGS)
 		break;
 	}
 
+	free(secname);
 	return(1);
 }
 
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-04-15  0:41 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=201404150041.s3F0fAJ7026138@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).