dovecot-2.2: imap-urlauth: Treat internal errors in URL fetching...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Sep 16 16:02:59 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/c69ee1de5f70
changeset: 15077:c69ee1de5f70
user: Stephan Bosch <stephan at rename-it.nl>
date: Sun Sep 16 16:02:18 2012 +0300
description:
imap-urlauth: Treat internal errors in URL fetching differently from invalid URLs.
diffstat:
src/imap-urlauth/imap-urlauth-worker.c | 4 ++
src/lib-imap-urlauth/imap-urlauth-fetch.c | 50 +++++++++++++++++-------------
2 files changed, 33 insertions(+), 21 deletions(-)
diffs (102 lines):
diff -r 7e1f0146169f -r c69ee1de5f70 src/imap-urlauth/imap-urlauth-worker.c
--- 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)
diff -r 7e1f0146169f -r c69ee1de5f70 src/lib-imap-urlauth/imap-urlauth-fetch.c
--- 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;
More information about the dovecot-cvs
mailing list