]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap-storage: imap-msgpart-url: Perform the check for a proper messagepart URL...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 13 Feb 2018 20:19:18 +0000 (21:19 +0100)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 14 Feb 2018 13:41:28 +0000 (15:41 +0200)
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.

src/lib-imap-storage/imap-msgpart-url.c

index 38a14545b79945937d3aff399eae6a93a2fde4a9..a58350a791aa0beb6936f8ac08fe76eab401d929 100644 (file)
@@ -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;