summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2022-04-24 17:39:32 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2022-04-24 17:39:32 +0000
commit227823efefe85c290c6861285dd4cfe92711d558 (patch)
treefd421b78fb5e5ff4391e440b947b1cadb201d3f3 /usr.bin/mandoc/roff.c
parent04d198e5b66cf644f9fbb2ac1d70f4498d13b6c3 (diff)
When we open a new .while loop, let's not attempt to close out
another enclosing .while loop at the same time. Instead, postpone the closing until the next iteration of ROFF_RERUN. This prevents one-line constructions like ".while 0 .while 0 something" and ".while rx .while rx .rr x" (which admittedly aren't particularly useful) from dying of abort(3), which was a bug tb@ found with afl(1).
Diffstat (limited to 'usr.bin/mandoc/roff.c')
-rw-r--r--usr.bin/mandoc/roff.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 6c268729506..7ea4f6e51bc 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.254 2022/04/24 13:34:53 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.255 2022/04/24 17:39:31 schwarze Exp $ */
/*
* Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -2431,9 +2431,11 @@ roff_cond_sub(ROFF_ARGS)
}
}
} else if (t != TOKEN_NONE &&
- (rr || roffs[t].flags & ROFFMAC_STRUCT))
+ (rr || roffs[t].flags & ROFFMAC_STRUCT)) {
irc |= (*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs);
- else
+ if (irc & ROFF_WHILE)
+ irc &= ~(ROFF_LOOPCONT | ROFF_LOOPEXIT);
+ } else
irc |= rr ? ROFF_CONT : ROFF_IGN;
return irc;
}