Mercurial > dovecot > core-2.2
changeset 15077:c69ee1de5f70
imap-urlauth: Treat internal errors in URL fetching differently from invalid URLs.
author | Stephan Bosch <stephan@rename-it.nl> |
---|---|
date | Sun, 16 Sep 2012 16:02:18 +0300 |
parents | 7e1f0146169f |
children | dc1db2eedbb1 |
files | src/imap-urlauth/imap-urlauth-worker.c src/lib-imap-urlauth/imap-urlauth-fetch.c |
diffstat | 2 files changed, 33 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap-urlauth/imap-urlauth-worker.c Sun Sep 16 16:02:15 2012 +0300 +++ b/src/imap-urlauth/imap-urlauth-worker.c Sun Sep 16 16:02:18 2012 +0300 @@ -377,6 +377,8 @@ if (imap_msgpart_url_get_bodypartstructure(client->url, bpstruct_r, &error) <= 0) { + if (ret < 0) + return -1; *errormsg_r = t_strdup_printf( "Failed to read URLAUTH \"%s\": %s", url, error); if (client->debug) @@ -389,6 +391,8 @@ if ((url_flags & IMAP_URLAUTH_FETCH_FLAG_BODY) != 0 || (url_flags & IMAP_URLAUTH_FETCH_FLAG_BINARY) != 0) { if (imap_msgpart_url_read_part(client->url, &mpresult, &error) <= 0) { + if (ret < 0) + return -1; *errormsg_r = t_strdup_printf( "Failed to read URLAUTH \"%s\": %s", url, error); if (client->debug)
--- a/src/lib-imap-urlauth/imap-urlauth-fetch.c Sun Sep 16 16:02:15 2012 +0300 +++ b/src/lib-imap-urlauth/imap-urlauth-fetch.c Sun Sep 16 16:02:18 2012 +0300 @@ -173,16 +173,13 @@ ret = imap_urlauth_fetch_parsed(ufetch->uctx, imap_url, &mpurl, &error_code, &error); } - if (ret < 0) { - (void)ufetch->callback(NULL, TRUE, ufetch->context); - imap_urlauth_fetch_fail(ufetch); - return; - } - if (ret == 0) { - errormsg = t_strdup_printf("Failed to fetch URLAUTH \"%s\": %s", - url, error); - if (debug) - i_debug("%s", errormsg); + if (ret <= 0) { + if (ret == 0) { + errormsg = t_strdup_printf("Failed to fetch URLAUTH \"%s\": %s", + url, error); + if (debug) + i_debug("%s", errormsg); + } success = FALSE; } @@ -191,12 +188,14 @@ imap_msgpart_url_set_decode_to_binary(mpurl); if (success && (url_flags & IMAP_URLAUTH_FETCH_FLAG_BODYPARTSTRUCTURE) != 0) { - if (imap_msgpart_url_get_bodypartstructure - (mpurl, &bpstruct, &error) <= 0) { - errormsg = t_strdup_printf - ("Failed to read URLAUTH \"%s\": %s", url, error); - if (debug) - i_debug("%s", errormsg); + ret = imap_msgpart_url_get_bodypartstructure(mpurl, &bpstruct, &error); + if (ret <= 0) { + if (ret == 0) { + errormsg = t_strdup_printf + ("Failed to read URLAUTH \"%s\": %s", url, error); + if (debug) + i_debug("%s", errormsg); + } success = FALSE; } } @@ -206,11 +205,14 @@ mpresult.input = NULL; if (success && ((url_flags & IMAP_URLAUTH_FETCH_FLAG_BODY) != 0 || (url_flags & IMAP_URLAUTH_FETCH_FLAG_BINARY) != 0)) { - if (imap_msgpart_url_read_part(mpurl, &mpresult, &error) <= 0) { - errormsg = t_strdup_printf - ("Failed to read URLAUTH \"%s\": %s", url, error); - if (debug) - i_debug("%s", errormsg); + ret = imap_msgpart_url_read_part(mpurl, &mpresult, &error); + if (ret <= 0) { + if (ret == 0) { + errormsg = t_strdup_printf + ("Failed to read URLAUTH \"%s\": %s", url, error); + if (debug) + i_debug("%s", errormsg); + } success = FALSE; } } @@ -227,6 +229,12 @@ } } + if (!success && ret < 0) { + (void)ufetch->callback(NULL, TRUE, ufetch->context); + imap_urlauth_fetch_fail(ufetch); + return; + } + memset(&reply, 0, sizeof(reply)); reply.url = url; reply.flags = url_flags;