From: Stephan Bosch Date: Tue, 13 Feb 2018 20:19:18 +0000 (+0100) Subject: lib-imap-storage: imap-msgpart-url: Perform the check for a proper messagepart URL... X-Git-Tag: 2.3.9~2311 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18b24aaee29db8f29bf45cae3b1b60c1f1a43758;p=thirdparty%2Fdovecot%2Fcore.git lib-imap-storage: imap-msgpart-url: Perform the check for a proper messagepart URL in imap_msgpart_url_create(). Before, this was an assert in imap_msgpart_url_create(). The actual check was performed only in imap_msgpart_url_parse(), meaning that imap_msgpart_url_create() would fail with an assertion when provided with an inappropriate URL. This surfaced as a problem for the submission BURL command. --- diff --git a/src/lib-imap-storage/imap-msgpart-url.c b/src/lib-imap-storage/imap-msgpart-url.c index 38a14545b7..a58350a791 100644 --- a/src/lib-imap-storage/imap-msgpart-url.c +++ b/src/lib-imap-storage/imap-msgpart-url.c @@ -38,9 +38,11 @@ int imap_msgpart_url_create(struct mail_user *user, const struct imap_url *url, struct imap_msgpart_url *mpurl; struct imap_msgpart *msgpart; - i_assert(url->mailbox != NULL && url->uid != 0 && - url->search_program == NULL); - + if (url->mailbox == NULL || url->uid == 0 || + url->search_program != NULL) { + *error_r = "Invalid messagepart IMAP URL"; + return -1; + } if (imap_msgpart_parse(section, &msgpart) < 0) { *error_r = "Invalid section"; return -1; @@ -92,10 +94,6 @@ int imap_msgpart_url_parse(struct mail_user *user, struct mailbox *selected_box, *error_r = "Mailbox-relative IMAP URL, but no mailbox selected"; return 0; } - if (url->uid == 0 || url->search_program != NULL) { - *error_r = "Invalid messagepart IMAP URL"; - return 0; - } if (imap_msgpart_url_create(user, url, mpurl_r, error_r) < 0) return -1; (*mpurl_r)->selected_box = selected_box;