tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: tech@mdocml.bsd.lv
Subject: infinite recursion regression fix
Date: Sat, 22 Oct 2011 23:03:58 +0200	[thread overview]
Message-ID: <20111022210358.GB8614@iris.usta.de> (raw)

Hi,

one of the recent releases introduced a regression with respect
to infinite recursion:  When string expansion exceeds the recursion
limit, groff drops the input line, and mandoc used to do the same.
Current mandoc, however, just leaves the string unexpanded.

The following patch restores compatible behaviour.

OK?
  Ingo


Index: roff.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/roff.c,v
retrieving revision 1.44
diff -u -p -r1.44 roff.c
--- roff.c	19 Sep 2011 07:53:54 -0000	1.44
+++ roff.c	22 Oct 2011 21:20:23 -0000
@@ -182,7 +182,7 @@ static	void		 roff_openeqn(struct roff *
 				int, int, const char *);
 static	enum rofft	 roff_parse(struct roff *, const char *, int *);
 static	enum rofferr	 roff_parsetext(char *);
-static	void		 roff_res(struct roff *, 
+static	enum rofferr	 roff_res(struct roff *, 
 				char **, size_t *, int, int);
 static	enum rofferr	 roff_rm(ROFF_ARGS);
 static	void		 roff_setstr(struct roff *,
@@ -428,7 +428,7 @@ roff_alloc(struct mparse *parse)
  * is processed. 
  * This also checks the syntax of regular escapes.
  */
-static void
+static enum rofferr
 roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos)
 {
 	enum mandoc_esc	 esc;
@@ -454,7 +454,7 @@ again:
 		 */
 
 		if ('\0' == *cp)
-			return;
+			return(ROFF_CONT);
 
 		if ('*' != *cp) {
 			res = cp;
@@ -465,7 +465,7 @@ again:
 			mandoc_msg
 				(MANDOCERR_BADESCAPE, r->parse, 
 				 ln, (int)(stesc - *bufp), NULL);
-			return;
+			return(ROFF_CONT);
 		}
 
 		cp++;
@@ -478,7 +478,7 @@ again:
 
 		switch (*cp) {
 		case ('\0'):
-			return;
+			return(ROFF_CONT);
 		case ('('):
 			cp++;
 			maxl = 2;
@@ -501,7 +501,7 @@ again:
 					(MANDOCERR_BADESCAPE, 
 					 r->parse, ln, 
 					 (int)(stesc - *bufp), NULL);
-				return;
+				return(ROFF_CONT);
 			}
 			if (0 == maxl && ']' == *cp)
 				break;
@@ -542,8 +542,9 @@ again:
 
 		/* Just leave the string unexpanded. */
 		mandoc_msg(MANDOCERR_ROFFLOOP, r->parse, ln, pos, NULL);
-		return;
+		return(ROFF_IGN);
 	}
+	return(ROFF_CONT);
 }
 
 /*
@@ -600,7 +601,10 @@ roff_parseln(struct roff *r, int ln, cha
 	 * words to fill in.
 	 */
 
-	roff_res(r, bufp, szp, ln, pos);
+	e = roff_res(r, bufp, szp, ln, pos);
+	if (ROFF_IGN == e)
+		return(e);
+	assert(ROFF_CONT == e);
 
 	ppos = pos;
 	ctl = mandoc_getcontrol(*bufp, &pos);
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

             reply	other threads:[~2011-10-22 21:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-22 21:03 Ingo Schwarze [this message]
2011-10-24 16:23 ` Kristaps Dzonsons

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=20111022210358.GB8614@iris.usta.de \
    --to=schwarze@usta.de \
    --cc=tech@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).