From: Timo Sirainen Date: Thu, 12 Jun 2014 21:51:44 +0000 (+0300) Subject: imapc: Avoid crashing if server happens to send invalid resp-text-codes. X-Git-Tag: 2.2.14.rc1~404 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d2d7c4d0458e534bee8621613865a06b44eae02;p=thirdparty%2Fdovecot%2Fcore.git imapc: Avoid crashing if server happens to send invalid resp-text-codes. If [KEY VALUE] is missing the VALUE, just set it to "" instead of NULL. Found by Coverity --- diff --git a/src/lib-imap-client/imapc-connection.c b/src/lib-imap-client/imapc-connection.c index bffcfa718c..7d0d1d681b 100644 --- a/src/lib-imap-client/imapc-connection.c +++ b/src/lib-imap-client/imapc-connection.c @@ -630,7 +630,7 @@ imapc_connection_handle_resp_text(struct imapc_connection *conn, *value_r = value + 1; } else { *key_r = text; - *value_r = NULL; + *value_r = ""; } return imapc_connection_handle_resp_text_code(conn, *key_r, *value_r); } diff --git a/src/lib-storage/index/imapc/imapc-mailbox.c b/src/lib-storage/index/imapc/imapc-mailbox.c index 36c51d8ffd..7b7eb23498 100644 --- a/src/lib-storage/index/imapc/imapc-mailbox.c +++ b/src/lib-storage/index/imapc/imapc-mailbox.c @@ -413,7 +413,7 @@ imapc_resp_text_uidvalidity(const struct imapc_untagged_reply *reply, { uint32_t uid_validity; - if (mbox == NULL || reply->resp_text_value == NULL || + if (mbox == NULL || str_to_uint32(reply->resp_text_value, &uid_validity) < 0) return; @@ -429,7 +429,7 @@ imapc_resp_text_uidnext(const struct imapc_untagged_reply *reply, { uint32_t uid_next; - if (mbox == NULL || reply->resp_text_value == NULL || + if (mbox == NULL || str_to_uint32(reply->resp_text_value, &uid_next) < 0) return;