From 520d5a6fc6a6cf100d9414d588079f2a076801c5 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 15 Apr 2015 16:09:53 -0700 Subject: Check return status of utf8proc_iterate. Closes #27. If unicode parsing gives an error condition, we just skip the rest of the string without rendering anything and proceed. I'm not sure if that's the best way to handle this, but garbage in, garbage out. Note: this bug was found using american fuzzy lop. --- src/man.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/man.c') diff --git a/src/man.c b/src/man.c index 27cd2e4..8ff4a9f 100644 --- a/src/man.c +++ b/src/man.c @@ -20,6 +20,9 @@ static void escape_man(cmark_strbuf *dest, const unsigned char *source, int leng while (i < length) { len = utf8proc_iterate(source + i, length - i, &c); + if (len == -1) { // error condition + return; // return without rendering anything + } switch(c) { case 46: if (beginLine) { -- cgit v1.2.3