aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandoc.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2022-04-13 13:19:34 +0000
committerIngo Schwarze <schwarze@openbsd.org>2022-04-13 13:19:34 +0000
commitca9bc03cff40f97d7cd61a8a1ad5f04878abee7a (patch)
tree26610d2bdaaa6010c584a31ecdea9305ababb927 /mandoc.c
parentef4cc03dbb7deeb4329a74e97c09433301435a54 (diff)
downloadmandoc-ca9bc03cff40f97d7cd61a8a1ad5f04878abee7a.tar.gz
mandoc-ca9bc03cff40f97d7cd61a8a1ad5f04878abee7a.tar.zst
mandoc-ca9bc03cff40f97d7cd61a8a1ad5f04878abee7a.zip
Surprisingly, groff supports multiple copy mode escapes at the
beginning of an escape sequence: \, \E, \EE, \EEE, and so on all do the same outside copy mode, so let them do the same in mandoc(1), too. This fixes an assertion failure triggered by \EE*X that tb@ found with afl(1). The first E was consumed by roff_expand(), but that function failed to recognize the escape sequence as the expansion of a user-defined string and handed it over to mandoc_escape(), which consumed the second E and then died on an assertion because it is not prepared to handle user-defined strings. Fix this by letting *both* functions handle arbitrary numbers of 'E's correctly.
Diffstat (limited to 'mandoc.c')
-rw-r--r--mandoc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mandoc.c b/mandoc.c
index 6adf1a43..92d18665 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -1,7 +1,7 @@
-/* $Id: mandoc.c,v 1.119 2021/08/10 12:55:03 schwarze Exp $ */
+/* $Id: mandoc.c,v 1.120 2022/04/13 13:19:34 schwarze Exp $ */
/*
+ * Copyright (c) 2011-2015, 2017-2022 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011-2015, 2017-2021 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -114,7 +114,7 @@ mandoc_escape(const char **end, const char **start, int *sz)
* it only makes a difference in copy mode.
*/
- if (**end == 'E')
+ while (**end == 'E')
++*end;
/*