tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* infinite recursion regression fix
@ 2011-10-22 21:03 Ingo Schwarze
  2011-10-24 16:23 ` Kristaps Dzonsons
  0 siblings, 1 reply; 2+ messages in thread
From: Ingo Schwarze @ 2011-10-22 21:03 UTC (permalink / raw)
  To: tech

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: infinite recursion regression fix
  2011-10-22 21:03 infinite recursion regression fix Ingo Schwarze
@ 2011-10-24 16:23 ` Kristaps Dzonsons
  0 siblings, 0 replies; 2+ messages in thread
From: Kristaps Dzonsons @ 2011-10-24 16:23 UTC (permalink / raw)
  To: tech; +Cc: Ingo Schwarze

On 10/22/11 23:03, Ingo Schwarze wrote:
> 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.

Ingo, yes, absolutely.

Thanks!

Kristaps
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-24 16:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-22 21:03 infinite recursion regression fix Ingo Schwarze
2011-10-24 16:23 ` Kristaps Dzonsons

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