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 q6CFBEvg027121 for ; Thu, 12 Jul 2012 11:11:14 -0400 (EDT) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id q6CFBEd0017221; Thu, 12 Jul 2012 11:11:14 -0400 (EDT) Date: Thu, 12 Jul 2012 11:11:14 -0400 (EDT) Message-Id: <201207121511.q6CFBEd0017221@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: The post_nm() validation function crashed when the first .Nm X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- The post_nm() validation function crashed when the first .Nm child node was a non-text node. Fix this by rewriting post_nm() to always set the meta name to UNKNOWN when the name is missing or unusable. While here, make MANDOCERR_NONAME an ERROR, as it usually renders the page content unintelligible. Bug reported by Maxim , thanks. OpenBSD rev. 1.105 Modified Files: -------------- mdocml: mandoc.h mdoc_validate.c read.c Revision Data ------------- Index: mdoc_validate.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v retrieving revision 1.186 retrieving revision 1.187 diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.186 -r1.187 --- mdoc_validate.c +++ mdoc_validate.c @@ -1123,24 +1123,29 @@ post_nm(POST_ARGS) char buf[BUFSIZ]; int c; - /* If no child specified, make sure we have the meta name. */ - - if (NULL == mdoc->last->child && NULL == mdoc->meta.name) { - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NONAME); - return(1); - } else if (mdoc->meta.name) + if (NULL != mdoc->meta.name) return(1); - /* If no meta name, set it from the child. */ + /* Try to use our children for setting the meta name. */ - buf[0] = '\0'; - if (-1 == (c = concat(buf, mdoc->last->child, BUFSIZ))) { + if (NULL != mdoc->last->child) { + buf[0] = '\0'; + c = concat(buf, mdoc->last->child, BUFSIZ); + } else + c = 0; + + switch (c) { + case (-1): mdoc_nmsg(mdoc, mdoc->last->child, MANDOCERR_MEM); return(0); + case (0): + mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NONAME); + mdoc->meta.name = mandoc_strdup("UNKNOWN"); + break; + default: + mdoc->meta.name = mandoc_strdup(buf); + break; } - - assert(c); - mdoc->meta.name = mandoc_strdup(buf); return(1); } Index: mandoc.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v retrieving revision 1.102 retrieving revision 1.103 diff -Lmandoc.h -Lmandoc.h -u -p -r1.102 -r1.103 --- mandoc.h +++ mandoc.h @@ -61,7 +61,6 @@ enum mandocerr { MANDOCERR_SO, /* .so is fragile, better use ln(1) */ MANDOCERR_NAMESECFIRST, /* NAME section must come first */ MANDOCERR_BADNAMESEC, /* bad NAME section contents */ - MANDOCERR_NONAME, /* manual name not yet set */ MANDOCERR_SECOOO, /* sections out of conventional order */ MANDOCERR_SECREP, /* duplicate section name */ MANDOCERR_SECMSEC, /* section not in conventional manual section */ @@ -129,6 +128,7 @@ enum mandocerr { MANDOCERR_ROFFLOOP, /* input stack limit exceeded, infinite loop? */ MANDOCERR_BADCHAR, /* skipping bad character */ MANDOCERR_NAMESC, /* escaped character not allowed in a name */ + MANDOCERR_NONAME, /* manual name not yet set */ MANDOCERR_NOTEXT, /* skipping text before the first section header */ MANDOCERR_MACRO, /* skipping unknown macro */ MANDOCERR_REQUEST, /* NOT IMPLEMENTED: skipping request */ Index: read.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v retrieving revision 1.29 retrieving revision 1.30 diff -Lread.c -Lread.c -u -p -r1.29 -r1.30 --- read.c +++ read.c @@ -106,7 +106,6 @@ static const char * const mandocerrs[MAN ".so is fragile, better use ln(1)", "NAME section must come first", "bad NAME section contents", - "manual name not yet set", "sections out of conventional order", "duplicate section name", "section not in conventional manual section", @@ -174,6 +173,7 @@ static const char * const mandocerrs[MAN "input stack limit exceeded, infinite loop?", "skipping bad character", "escaped character not allowed in a name", + "manual name not yet set", "skipping text before the first section header", "skipping unknown macro", "NOT IMPLEMENTED, please use groff: skipping request", -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv