]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
zlib: Fixed the check to disallow saving messages that look compressed.
authorTimo Sirainen <tss@iki.fi>
Fri, 19 Feb 2010 12:22:19 +0000 (14:22 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 19 Feb 2010 12:22:19 +0000 (14:22 +0200)
--HG--
branch : HEAD

src/plugins/zlib/zlib-plugin.c

index 4ab737fd3b921e597829a7742207fce2b7df52fd..f711babc1fd2ea9a213b72ba32b774a78224708d 100644 (file)
@@ -131,13 +131,19 @@ static int zlib_permail_get_stream(struct mail *_mail,
                                   struct message_size *body_size,
                                   struct istream **stream_r)
 {
+       struct zlib_user *zuser = ZLIB_USER_CONTEXT(_mail->box->storage->user);
        struct mail_private *mail = (struct mail_private *)_mail;
        struct index_mail *imail = (struct index_mail *)mail;
        union mail_module_context *zmail = ZLIB_MAIL_CONTEXT(mail);
        struct istream *input;
        const struct zlib_handler *handler;
 
-       if (imail->data.stream != NULL) {
+       /* don't uncompress input when we are reading a mail that we're just
+          in the middle of saving, and we didn't do the compression ourself.
+          in such situation we're probably checking if the user-given input
+          looks compressed */
+       if (imail->data.stream != NULL ||
+           (_mail->uid == 0 && zuser->save_handler == NULL)) {
                return zmail->super.get_stream(_mail, hdr_size, body_size,
                                               stream_r);
        }