]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Fixed a crash with fetch (rfc822.size body). Also fixed it so it doesn't
authorTimo Sirainen <tss@iki.fi>
Fri, 23 Jul 2004 18:36:10 +0000 (21:36 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 23 Jul 2004 18:36:10 +0000 (21:36 +0300)
anymore parse the message body twice.

--HG--
branch : HEAD

src/lib-storage/index/index-mail.c
src/lib-storage/index/index-mail.h

index fcc5363f59629317f8261a175e169d1ff8063e8e..8228623b38f9fb0b898d24fd07d38f3b5bb9effc 100644 (file)
@@ -307,6 +307,8 @@ static void index_mail_parse_body(struct index_mail *mail, int need_parts)
                message_parser_parse_body(data->parser_ctx,
                                          parse_bodystructure_part_header,
                                          NULL, mail->pool);
+               data->save_bodystructure_body = FALSE;
+               data->parsed_bodystructure = TRUE;
        } else {
                message_parser_parse_body(data->parser_ctx, NULL, NULL, NULL);
        }
@@ -406,21 +408,28 @@ static void index_mail_parse_bodystructure(struct index_mail *mail,
        string_t *str;
        int bodystructure_cached = FALSE;
 
-       if (data->save_bodystructure_header || !data->save_bodystructure_body) {
-               /* we haven't parsed the header yet */
-               data->save_bodystructure_header = TRUE;
-               data->save_bodystructure_body = TRUE;
-               if (!index_mail_parse_headers(mail, NULL))
-                       return;
-       }
+       if (!data->parsed_bodystructure) {
+               if (data->save_bodystructure_header ||
+                   !data->save_bodystructure_body) {
+                       /* we haven't parsed the header yet */
+                       data->save_bodystructure_header = TRUE;
+                       data->save_bodystructure_body = TRUE;
+                       if (!index_mail_parse_headers(mail, NULL))
+                               return;
+               }
 
-       if (data->parts != NULL) {
-               i_assert(data->parts->next == NULL);
-               message_parse_from_parts(data->parts->children, data->stream,
-                                        parse_bodystructure_part_header,
-                                        mail->pool);
-       } else {
-               index_mail_parse_body(mail, FALSE);
+               if (data->parts != NULL) {
+                       i_assert(data->parts->next == NULL);
+                       i_stream_seek(data->stream,
+                                     data->hdr_size.physical_size);
+                       message_parse_from_parts(data->parts->children,
+                                               data->stream,
+                                               parse_bodystructure_part_header,
+                                               mail->pool);
+                       data->parsed_bodystructure = TRUE;
+               } else {
+                       index_mail_parse_body(mail, FALSE);
+               }
        }
 
        dec = mail_cache_field_get_decision(mail->ibox->cache,
index c67207f2885c9b37d4575d9efbb44b8791b2ee23..c902de50e09755761aae4bd7315dec8b0cd9ea0f 100644 (file)
@@ -77,6 +77,7 @@ struct index_mail_data {
        unsigned int save_sent_date:1;
        unsigned int save_bodystructure_header:1;
        unsigned int save_bodystructure_body:1;
+       unsigned int parsed_bodystructure:1;
        unsigned int hdr_size_set:1;
        unsigned int body_size_set:1;
        unsigned int open_mail:1;