Skip to content

Commit f904cbd

Browse files
sirainencmouse
authored andcommitted
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.
1 parent 85fcb89 commit f904cbd

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/lib-imap/imap-parser.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,8 @@ static void imap_parser_save_arg(struct imap_parser *parser,
267267

268268
/* remove the escapes */
269269
if (parser->str_first_escape >= 0 &&
270-
(parser->flags & IMAP_PARSE_FLAG_NO_UNESCAPE) == 0) {
271-
/* -1 because we skipped the '"' prefix */
272-
(void)str_unescape(str + parser->str_first_escape-1);
273-
}
270+
(parser->flags & IMAP_PARSE_FLAG_NO_UNESCAPE) == 0)
271+
(void)str_unescape(str);
274272
arg->_data.str = str;
275273
arg->str_len = strlen(str);
276274
break;

0 commit comments

Comments
 (0)