]> 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, 24 May 2019 08:53:54 +0000 (11:53 +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 cf2ffd9de6b9d7938170df153add06f65708e954..98a90928ce1ed8ed8fd6379fbeed1fa825a1a560 100644 (file)
@@ -256,10 +256,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;