source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Using macros in .Sh header lines, or having .Sm off or .Bk
@ 2014-04-15  0:41 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-04-15  0:41 UTC (permalink / raw)
  To: source

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-15  0:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-15  0:41 mdocml: Using macros in .Sh header lines, or having .Sm off or .Bk schwarze

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).