[dovecot-cvs] dovecot/src/imap imap-fetch-body-section.c,1.15,1.16
cras at procontrol.fi
cras at procontrol.fi
Mon Sep 15 22:04:14 EEST 2003
Update of /home/cvs/dovecot/src/imap
In directory danu:/tmp/cvs-serv10603
Modified Files:
imap-fetch-body-section.c
Log Message:
If client requests invalid body part, return it as NIL.
Index: imap-fetch-body-section.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-fetch-body-section.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- imap-fetch-body-section.c 6 Aug 2003 20:15:30 -0000 1.15
+++ imap-fetch-body-section.c 15 Sep 2003 18:04:12 -0000 1.16
@@ -397,9 +397,8 @@
}
/* Find message_part for section (eg. 1.3.4) */
-static const struct message_part *
-part_find(struct mail *mail, const struct imap_fetch_body_data *body,
- const char **section)
+static int part_find(struct mail *mail, const struct imap_fetch_body_data *body,
+ const struct message_part **part_r, const char **section)
{
const struct message_part *part;
const char *path;
@@ -407,7 +406,7 @@
part = mail->get_parts(mail);
if (part == NULL)
- return NULL;
+ return FALSE;
path = body->section;
while (*path >= '0' && *path <= '9' && part != NULL) {
@@ -431,7 +430,7 @@
} else {
/* only 1 allowed with non-multipart messages */
if (num != 1)
- return NULL;
+ part = NULL;
}
if (part != NULL &&
@@ -441,8 +440,9 @@
}
}
+ *part_r = part;
*section = path;
- return part;
+ return TRUE;
}
/* fetch BODY[1.2] or BODY[1.2.TEXT] */
@@ -488,9 +488,14 @@
const struct message_part *part;
const char *section;
- part = part_find(mail, body, §ion);
- if (part == NULL)
+ if (!part_find(mail, body, &part, §ion))
return FALSE;
+
+ if (part == NULL) {
+ /* part doesn't exist */
+ return o_stream_send_str(ctx->output, ctx->prefix) > 0 &&
+ o_stream_send_str(ctx->output, " NIL") > 0;
+ }
stream = mail->get_stream(mail, NULL, NULL);
if (stream == NULL)
More information about the dovecot-cvs
mailing list