From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Do not abuse assert(3) to react to absurd input; the purpose of
Date: Wed, 9 Sep 2020 08:45:35 -0500 (EST) [thread overview]
Message-ID: <f200ead376b76b53@mandoc.bsd.lv> (raw)
Log Message:
-----------
Do not abuse assert(3) to react to absurd input; the purpose of assert(3)
only is to catch internal inconsistencies in the program itself.
Issue found in an afl run performed by Jan Schreiber <jes at posteo dot de>.
Instead, just cut down unreasonably wide spacing requested by the document
to a narrower width.
Modified Files:
--------------
mandoc:
term_ascii.c
Revision Data
-------------
Index: term_ascii.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/term_ascii.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -Lterm_ascii.c -Lterm_ascii.c -u -p -r1.65 -r1.66
--- term_ascii.c
+++ term_ascii.c
@@ -245,7 +245,14 @@ ascii_advance(struct termp *p, size_t le
{
size_t i;
- assert(len < UINT16_MAX);
+ /*
+ * XXX We used to have "assert(len < UINT16_MAX)" here.
+ * that is not quite right because the input document
+ * can trigger that by merely providing large input.
+ * For now, simply truncate.
+ */
+ if (len > 256)
+ len = 256;
for (i = 0; i < len; i++)
putchar(' ');
}
@@ -383,7 +390,14 @@ locale_advance(struct termp *p, size_t l
{
size_t i;
- assert(len < UINT16_MAX);
+ /*
+ * XXX We used to have "assert(len < UINT16_MAX)" here.
+ * that is not quite right because the input document
+ * can trigger that by merely providing large input.
+ * For now, simply truncate.
+ */
+ if (len > 256)
+ len = 256;
for (i = 0; i < len; i++)
putwchar(L' ');
}
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2020-09-09 13:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f200ead376b76b53@mandoc.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).