From 269640a83ac140b48aaa191eec13ead5dd60519a Mon Sep 17 00:00:00 2001
From: maminjie <maminjie1@huawei.com>
Date: Thu, 3 Jun 2021 11:24:44 +0800
Subject: [PATCH] Handle empty lists in IMAP BODYSTRUCTURE parsing as invalid

reference: https://github.com/dovecot/core/commit/586cca576970cc377a40f995512dbc02981900a3
---
 src/lib-imap/imap-bodystructure.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/lib-imap/imap-bodystructure.c b/src/lib-imap/imap-bodystructure.c
index b52af28..07bd5a4 100644
--- a/src/lib-imap/imap-bodystructure.c
+++ b/src/lib-imap/imap-bodystructure.c
@@ -276,6 +276,8 @@ imap_bodystructure_params_parse(const struct imap_arg *arg,
 		return -1;
 	if ((list_count % 2) != 0)
 		return -1;
+    if (list_count == 0)
+        return -1;
 
 	params_count = list_count/2;
 	params = p_new(pool, struct message_part_param, params_count+1);
-- 
2.23.0

