diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2022-04-13 14:37:35 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2022-04-13 14:37:35 +0000 |
commit | ec6d7bc95596f99f8827bc3ef4d6b12a131c88f8 (patch) | |
tree | 08b083943726f3368f6458fcff493c6e5d2dac6a /usr.bin | |
parent | 240f27e00afafd9b3622f47e0cf87da52217f4b1 (diff) |
Do not die on an assertion if an input file contains no section
whatsoever and ends with a broken next-line scope. Obviously, this
cannot happen in a real manual page, but mandoc(1) should not die
even when fed absurd input.
This bug was independently reported by both jsg@ and tb@ who both
found it with afl(1).
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/man_macro.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c index dc3832d1039..779b28278fe 100644 --- a/usr.bin/mandoc/man_macro.c +++ b/usr.bin/mandoc/man_macro.c @@ -1,7 +1,7 @@ -/* $OpenBSD: man_macro.c,v 1.107 2020/09/09 16:57:05 schwarze Exp $ */ +/* $OpenBSD: man_macro.c,v 1.108 2022/04/13 14:37:34 schwarze Exp $ */ /* + * Copyright (c) 2012-2015,2017-2020,2022 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2012-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de> * * Permission to use, copy, modify, and distribute this software for any @@ -106,7 +106,8 @@ man_unscope(struct roff_man *man, const struct roff_node *to) n->line, n->pos, "EOF breaks %s", roff_name[n->tok]); if (man->flags & MAN_ELINE) { - if ((man_macro(n->parent->tok)->flags & + if (n->parent->type == ROFFT_ROOT || + (man_macro(n->parent->tok)->flags & MAN_ESCOPED) == 0) man->flags &= ~MAN_ELINE; } else { |