Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Oct 2017 07:50:44 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r324581 - stable/11/contrib/mdocml
Message-ID:  <201710130750.v9D7oitE062045@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Fri Oct 13 07:50:44 2017
New Revision: 324581
URL: https://svnweb.freebsd.org/changeset/base/324581

Log:
  MFC: r324362
  
  Import mandoc 1.14.3

Modified:
  stable/11/contrib/mdocml/Makefile
  stable/11/contrib/mdocml/NEWS
  stable/11/contrib/mdocml/man_term.c
  stable/11/contrib/mdocml/mansearch.c
  stable/11/contrib/mdocml/mdoc_validate.c
  stable/11/contrib/mdocml/tbl_html.c
  stable/11/contrib/mdocml/tbl_term.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/mdocml/Makefile
==============================================================================
--- stable/11/contrib/mdocml/Makefile	Fri Oct 13 06:49:07 2017	(r324580)
+++ stable/11/contrib/mdocml/Makefile	Fri Oct 13 07:50:44 2017	(r324581)
@@ -15,7 +15,7 @@
 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-VERSION = 1.14.2
+VERSION = 1.14.3
 
 # === LIST OF FILES ====================================================
 

Modified: stable/11/contrib/mdocml/NEWS
==============================================================================
--- stable/11/contrib/mdocml/NEWS	Fri Oct 13 06:49:07 2017	(r324580)
+++ stable/11/contrib/mdocml/NEWS	Fri Oct 13 07:50:44 2017	(r324581)
@@ -2,6 +2,21 @@ $Id: NEWS,v 1.26 2017/07/28 14:57:56 schwarze Exp $
 
 This file lists the most important changes in the mandoc.bsd.lv distribution.
 
+Changes in version 1.14.3, released on August 5, 2017
+
+    --- BUG FIXES ---
+ * man(7): Do not crash with out-of-bounds read access to a constant
+   array if .sp or a blank line immediately precedes .SS or .SH.
+ * mdoc(7): Do not crash with out-of-bounds read access to a constant
+   array if .sp or a blank line precede the first .Sh macro.
+ * tbl(7): Ignore explicitly specified negative column widths rather than
+   wrapping around to huge numbers and risking memory exhaustion.
+ * man(1): No longer use names that only occur in the SYNOPSIS section.
+   Gets rid of some surprising behaviour and bogus warnings.
+    --- THANKS TO ---
+   Leah Neukirchen (Void Linux), Markus Waldeck (Debian),
+   Peter Bui (nd.edu), and Yuri Pankov (illumos) for bug reports.
+
 Changes in version 1.14.2, released on July 28, 2017
 
     --- MAJOR NEW FEATURES ---

Modified: stable/11/contrib/mdocml/man_term.c
==============================================================================
--- stable/11/contrib/mdocml/man_term.c	Fri Oct 13 06:49:07 2017	(r324580)
+++ stable/11/contrib/mdocml/man_term.c	Fri Oct 13 07:50:44 2017	(r324581)
@@ -1,4 +1,4 @@
-/*	$Id: man_term.c,v 1.208 2017/06/25 11:42:02 schwarze Exp $ */
+/*	$Id: man_term.c,v 1.209 2017/07/31 15:19:06 schwarze Exp $ */
 /*
  * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -673,7 +673,7 @@ pre_SS(DECL_ARGS)
 
 		do {
 			n = n->prev;
-		} while (n != NULL && n->tok != TOKEN_NONE &&
+		} while (n != NULL && n->tok >= MAN_TH &&
 		    termacts[n->tok].flags & MAN_NOTEXT);
 		if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL))
 			break;
@@ -735,7 +735,7 @@ pre_SH(DECL_ARGS)
 
 		do {
 			n = n->prev;
-		} while (n != NULL && n->tok != TOKEN_NONE &&
+		} while (n != NULL && n->tok >= MAN_TH &&
 		    termacts[n->tok].flags & MAN_NOTEXT);
 		if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL))
 			break;

Modified: stable/11/contrib/mdocml/mansearch.c
==============================================================================
--- stable/11/contrib/mdocml/mansearch.c	Fri Oct 13 06:49:07 2017	(r324580)
+++ stable/11/contrib/mdocml/mansearch.c	Fri Oct 13 07:50:44 2017	(r324581)
@@ -1,4 +1,4 @@
-/*	$OpenBSD: mansearch.c,v 1.50 2016/07/09 15:23:36 schwarze Exp $ */
+/*	$Id: mansearch.c,v 1.76 2017/08/02 13:29:04 schwarze Exp $ */
 /*
  * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2013-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -171,7 +171,9 @@ mansearch(const struct mansearch *search,
 			page = dbm_page_get(rp->page);
 
 			if (lstmatch(search->sec, page->sect) == 0 ||
-			    lstmatch(search->arch, page->arch) == 0)
+			    lstmatch(search->arch, page->arch) == 0 ||
+			    (search->argmode == ARG_NAME &&
+			     rp->bits <= (int32_t)(NAME_SYN & NAME_MASK)))
 				continue;
 
 			if (res == NULL) {
@@ -452,14 +454,28 @@ lstlen(const char *cp, size_t sep)
 {
 	size_t	 sz;
 
-	for (sz = 0;; sz++) {
-		if (cp[0] == '\0') {
-			if (cp[1] == '\0')
-				break;
-			sz += sep - 1;
-		} else if (cp[0] < ' ')
-			sz--;
-		cp++;
+	for (sz = 0; *cp != '\0'; cp++) {
+
+		/* Skip names appearing only in the SYNOPSIS. */
+		if (*cp <= (char)(NAME_SYN & NAME_MASK)) {
+			while (*cp != '\0')
+				cp++;
+			continue;
+		}
+
+		/* Skip name class markers. */
+		if (*cp < ' ')
+			cp++;
+
+		/* Print a separator before each but the first string. */
+		if (sz)
+			sz += sep;
+
+		/* Copy one string. */
+		while (*cp != '\0') {
+			sz++;
+			cp++;
+		}
 	}
 	return sz;
 }
@@ -471,19 +487,34 @@ lstlen(const char *cp, size_t sep)
 static void
 lstcat(char *buf, size_t *i, const char *cp, const char *sep)
 {
-	const char *s;
+	const char	*s;
+	size_t		 i_start;
 
-	for (;;) {
-		if (cp[0] == '\0') {
-			if (cp[1] == '\0')
-				break;
+	for (i_start = *i; *cp != '\0'; cp++) {
+
+		/* Skip names appearing only in the SYNOPSIS. */
+		if (*cp <= (char)(NAME_SYN & NAME_MASK)) {
+			while (*cp != '\0')
+				cp++;
+			continue;
+		}
+
+		/* Skip name class markers. */
+		if (*cp < ' ')
+			cp++;
+
+		/* Print a separator before each but the first string. */
+		if (*i > i_start) {
 			s = sep;
 			while (*s != '\0')
 				buf[(*i)++] = *s++;
-		} else if (cp[0] >= ' ')
-			buf[(*i)++] = cp[0];
-		cp++;
+		}
+
+		/* Copy one string. */
+		while (*cp != '\0')
+			buf[(*i)++] = *cp++;
 	}
+
 }
 
 /*

Modified: stable/11/contrib/mdocml/mdoc_validate.c
==============================================================================
--- stable/11/contrib/mdocml/mdoc_validate.c	Fri Oct 13 06:49:07 2017	(r324580)
+++ stable/11/contrib/mdocml/mdoc_validate.c	Fri Oct 13 07:50:44 2017	(r324581)
@@ -1,4 +1,4 @@
-/*	$Id: mdoc_validate.c,v 1.350 2017/07/20 12:54:02 schwarze Exp $ */
+/*	$Id: mdoc_validate.c,v 1.352 2017/08/02 13:29:04 schwarze Exp $ */
 /*
  * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1137,8 +1137,6 @@ post_fname(POST_ARGS)
 	if ( ! (cp[0] == '\0' || (cp[0] == '(' && cp[1] == '*')))
 		mandoc_msg(MANDOCERR_FN_PAREN, mdoc->parse,
 		    n->line, n->pos + pos, n->string);
-	if (n->sec == SEC_SYNOPSIS && mdoc->meta.msec != NULL)
-		mandoc_xr_add(mdoc->meta.msec, n->string, -1, -1);
 }
 
 static void
@@ -1205,9 +1203,8 @@ post_nm(POST_ARGS)
 
 	n = mdoc->last;
 
-	if ((n->sec == SEC_NAME || n->sec == SEC_SYNOPSIS) &&
-	    n->child != NULL && n->child->type == ROFFT_TEXT &&
-	    mdoc->meta.msec != NULL)
+	if (n->sec == SEC_NAME && n->child != NULL &&
+	    n->child->type == ROFFT_TEXT && mdoc->meta.msec != NULL)
 		mandoc_xr_add(mdoc->meta.msec, n->child->string, -1, -1);
 
 	if (n->last != NULL &&
@@ -1931,7 +1928,7 @@ post_root(POST_ARGS)
 	/* Check that we begin with a proper `Sh'. */
 
 	n = mdoc->first->child;
-	while (n != NULL && n->tok != TOKEN_NONE &&
+	while (n != NULL && n->tok >= MDOC_Dd &&
 	    mdoc_macros[n->tok].flags & MDOC_PROLOGUE)
 		n = n->next;
 

Modified: stable/11/contrib/mdocml/tbl_html.c
==============================================================================
--- stable/11/contrib/mdocml/tbl_html.c	Fri Oct 13 06:49:07 2017	(r324580)
+++ stable/11/contrib/mdocml/tbl_html.c	Fri Oct 13 07:50:44 2017	(r324581)
@@ -1,4 +1,4 @@
-/*	$Id: tbl_html.c,v 1.22 2017/06/12 20:14:18 schwarze Exp $ */
+/*	$Id: tbl_html.c,v 1.23 2017/07/31 16:14:10 schwarze Exp $ */
 /*
  * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -49,6 +49,9 @@ html_tbl_strlen(const char *p, void *arg)
 static size_t
 html_tbl_sulen(const struct roffsu *su, void *arg)
 {
+	if (su->scale < 0.0)
+		return 0;
+
 	switch (su->unit) {
 	case SCALE_FS:  /* 2^16 basic units */
 		return su->scale * 65536.0 / 24.0;

Modified: stable/11/contrib/mdocml/tbl_term.c
==============================================================================
--- stable/11/contrib/mdocml/tbl_term.c	Fri Oct 13 06:49:07 2017	(r324580)
+++ stable/11/contrib/mdocml/tbl_term.c	Fri Oct 13 07:50:44 2017	(r324581)
@@ -1,4 +1,4 @@
-/*	$Id: tbl_term.c,v 1.56 2017/07/08 13:43:15 schwarze Exp $ */
+/*	$Id: tbl_term.c,v 1.57 2017/07/31 16:14:10 schwarze Exp $ */
 /*
  * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011,2012,2014,2015,2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -51,7 +51,10 @@ static	void	tbl_word(struct termp *, const struct tbl_
 static size_t
 term_tbl_sulen(const struct roffsu *su, void *arg)
 {
-	return term_hen((const struct termp *)arg, su);
+	int	 i;
+
+	i = term_hen((const struct termp *)arg, su);
+	return i > 0 ? i : 0;
 }
 
 static size_t



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710130750.v9D7oitE062045>