From 05320b62b74ecf9f32d7db896575a45e79b02ff3 Mon Sep 17 00:00:00 2001 From: Marco Bettini Date: Tue, 21 Feb 2023 10:04:36 +0000 Subject: [PATCH] imap: imap_parser_read_next_atom() - Reject special character DEL 0x7F atom-specials includes CTL, which in turn contains \x00-\x1F and \x7F DEL --- src/lib-imap/imap-parser.c | 2 +- src/lib-imap/test-imap-parser.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib-imap/imap-parser.c b/src/lib-imap/imap-parser.c index 82de03e293..643f80ceeb 100644 --- a/src/lib-imap/imap-parser.c +++ b/src/lib-imap/imap-parser.c @@ -1001,7 +1001,7 @@ imap_parser_read_next_atom(struct imap_parser *parser, bool parsing_tag, break; default: if ((unsigned char)data[i] < ' ' || - (unsigned char)data[i] >= 0x80) + (unsigned char)data[i] >= 0x7F) return -1; } } diff --git a/src/lib-imap/test-imap-parser.c b/src/lib-imap/test-imap-parser.c index 906e63ca78..8a09422282 100644 --- a/src/lib-imap/test-imap-parser.c +++ b/src/lib-imap/test-imap-parser.c @@ -100,8 +100,11 @@ static void test_imap_parser_read_tag_cmd(void) { "\n", NULL, -1, BOTH }, { "tag", NULL, 0, BOTH }, { "tag\t", NULL, -1, BOTH }, - { "tag\001", NULL, -1, BOTH }, + { "tag\x01", NULL, -1, BOTH }, + { "tag\x1f", NULL, -1, BOTH }, + { "tag\x7f", NULL, -1, BOTH }, { "tag\x80", NULL, -1, BOTH }, + { "tag\xff", NULL, -1, BOTH }, { "tag(", NULL, -1, BOTH }, { "tag)", NULL, -1, BOTH }, { "tag{", NULL, -1, BOTH }, -- 2.47.3