]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap: Make sure str_unescape() won't be writing past allocated memory
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 17 May 2019 07:33:53 +0000 (10:33 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 23 Aug 2019 06:39:00 +0000 (09:39 +0300)
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.

src/lib-imap/imap-parser.c

index f41668d7a53e7158bfe26208d7ec5abd15480b16..7f58d99e2f912aea9e0a8b1bbc66ff817101f84f 100644 (file)
@@ -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;