From 05578bfcb6e753fdce2f0b5d7c4167fe326b4a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20S=C3=A1ez?= Date: Mon, 25 Aug 2014 18:27:11 +0200 Subject: [PATCH] oc-rtf: control words can also have a space before next tag This was causing to parse a single space as an empty control word with length 0, which was the source of several crashes. Example: \f0\fbidi \fcharset0 --------^ font index is 0, font family is bidi but when parsing charset we were assuming control word was '' instead of 'charset0'. This only fixes the crashes, the parseFontTable function works quite awful right now. --- OpenChange/RTFHandler.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenChange/RTFHandler.m b/OpenChange/RTFHandler.m index 65d5660ca..2f3b16ad4 100644 --- a/OpenChange/RTFHandler.m +++ b/OpenChange/RTFHandler.m @@ -412,16 +412,17 @@ const unsigned short ansicpg874[256] = { - (const char *) parseControlWord: (unsigned int *) len { const char *start, *end; - + start = ADVANCE; - - while (isalnum(*_bytes) || *_bytes == '-') + + while (isalnum(*_bytes) || *_bytes == '-' || isspace(*_bytes)) { ADVANCE; } end = _bytes; - + *len = end-start-1; + return start+1; }