From: Timo Sirainen Date: Fri, 17 May 2019 07:33:53 +0000 (+0300) Subject: lib-imap: Make sure str_unescape() won't be writing past allocated memory X-Git-Tag: 2.3.9~268 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5e3a8fed685af7ed45d584f5406e9dd2a490669;p=thirdparty%2Fdovecot%2Fcore.git 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. --- diff --git a/src/lib-imap/imap-parser.c b/src/lib-imap/imap-parser.c index f41668d7a5..7f58d99e2f 100644 --- a/src/lib-imap/imap-parser.c +++ b/src/lib-imap/imap-parser.c @@ -267,10 +267,8 @@ static void imap_parser_save_arg(struct imap_parser *parser, /* 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;