changeset 23016:d133ed304c89

lib-imap: Make sure str_unescape() won't be writing past allocated memory The previous commit should already prevent this, but this makes sure it can't become broken in the future either. It makes the performance a tiny bit worse, but that's not practically noticeable.
author Timo Sirainen <timo.sirainen@open-xchange.com>
date Fri, 17 May 2019 10:33:53 +0300
parents ae4659f289a9
children c1d36f2575c7
files src/lib-imap/imap-parser.c
diffstat 1 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap/imap-parser.c	Fri May 10 19:24:51 2019 +0300
+++ b/src/lib-imap/imap-parser.c	Fri May 17 10:33:53 2019 +0300
@@ -256,10 +256,8 @@
 
 		/* remove the escapes */
 		if (parser->str_first_escape >= 0 &&
-		    (parser->flags & IMAP_PARSE_FLAG_NO_UNESCAPE) == 0) {
-			/* -1 because we skipped the '"' prefix */
-			(void)str_unescape(str + parser->str_first_escape-1);
-		}
+		    (parser->flags & IMAP_PARSE_FLAG_NO_UNESCAPE) == 0)
+			(void)str_unescape(str);
 		arg->_data.str = str;
 		arg->str_len = strlen(str);
 		break;