summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/arch.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2022-04-13 20:19:20 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2022-04-13 20:19:20 +0000
commitf103a8be64783213f4419f7145b5ad93389b6f9b (patch)
tree83d9f3430a1bd2f60d90f3ece509dfc60a2c9b3c /usr.bin/mandoc/arch.c
parenta42ece57e3acde8b718e9e1fabe9c5de6bd84d88 (diff)
To prevent infinite recursion while expanding eqn(7) definitions,
we must not reset the recursion counter when moving beyond the end of the *previous* expansion, but we may only do so when moving beyond the rightmost position reached by *any* expansion in the current equation. This matters because definitions can nest; consider: .EQ define inner "content" define outer "inner outer" outer .EN This endless loop was found by tb@ using afl(1). Incidentally, GNU eqn(1) also performs an infinite loop in this situation and then crashes when memory runs out, but that's not an excuse for nasty behaviour of mandoc(1). While here, consistently print the expanded content even when the expansion is finally truncated. While that is not likely to help end-users, it may help authors of eqn(7) code to understand what's going on. Besides, it sends a very clear signal that something is amiss, which was easy to miss in the past unless people enabled -W error or used -T lint.
Diffstat (limited to 'usr.bin/mandoc/arch.c')
0 files changed, 0 insertions, 0 deletions