aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog8
-rw-r--r--camel/camel-multipart-encrypted.c16
2 files changed, 16 insertions, 8 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 93a88e2024..c3610f2bef 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,13 @@
2002-07-12 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-multipart-encrypted.c (camel_multipart_encrypted_decrypt):
+ On error, do not unref the parts gotten using
+ camel_multipart_get_part() since that function does not ref the
+ parts. Also don't forget to reset the decrypted stream before
+ trying to parse it ;-)
+
+2002-07-12 Jeffrey Stedfast <fejj@ximian.com>
+
* camel-multipart.c (camel_multipart_class_init): Updated to not
use camel_type_get_global_classfuncs() since this is just a cast
macro now.
diff --git a/camel/camel-multipart-encrypted.c b/camel/camel-multipart-encrypted.c
index b8856ad799..d44d712322 100644
--- a/camel/camel-multipart-encrypted.c
+++ b/camel/camel-multipart-encrypted.c
@@ -25,12 +25,14 @@
#include <config.h>
#endif
+#include <stdio.h>
#include <string.h>
#include "camel-multipart-encrypted.h"
#include "camel-mime-filter-crlf.h"
#include "camel-stream-filter.h"
#include "camel-stream-mem.h"
+#include "camel-stream-fs.h"
#include "camel-mime-utils.h"
#include "camel-mime-part.h"
@@ -181,7 +183,7 @@ camel_multipart_encrypted_encrypt (CamelMultipartEncrypted *mpe, CamelMimePart *
/* construct the version part */
stream = camel_stream_mem_new ();
- camel_stream_write_string (stream, "Version: 1");
+ camel_stream_write_string (stream, "Version: 1\n");
camel_stream_reset (stream);
version_part = camel_mime_part_new ();
@@ -263,15 +265,14 @@ camel_multipart_encrypted_decrypt (CamelMultipartEncrypted *mpe,
protocol = cipher->encrypt_protocol;
}
- version_part = camel_multipart_get_part (CAMEL_MULTIPART (mpe), CAMEL_MULTIPART_ENCRYPTED_VERSION);
-
/* make sure the protocol matches the version part's content-type */
- content_type = camel_data_wrapper_get_mime_type ((CamelDataWrapper *) version_part);
+ version_part = camel_multipart_get_part (CAMEL_MULTIPART (mpe), CAMEL_MULTIPART_ENCRYPTED_VERSION);
+ wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (version_part));
+ content_type = camel_data_wrapper_get_mime_type (wrapper);
if (strcasecmp (content_type, protocol) != 0) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to decrypt MIME part: protocol error"));
- camel_object_unref (version_part);
g_free (content_type);
return NULL;
@@ -284,14 +285,12 @@ camel_multipart_encrypted_decrypt (CamelMultipartEncrypted *mpe,
if (!header_content_type_is (mime_type, "application", "octet-stream")) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to decrypt MIME part: invalid structure"));
- camel_object_unref (encrypted_part);
- camel_object_unref (version_part);
return NULL;
}
/* get the ciphertext stream */
ciphertext = camel_stream_mem_new ();
- wrapper = camel_medium_get_content_object ((CamelMedium *) encrypted_part);
+ wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (encrypted_part));
camel_data_wrapper_write_to_stream (wrapper, ciphertext);
camel_stream_reset (ciphertext);
@@ -314,6 +313,7 @@ camel_multipart_encrypted_decrypt (CamelMultipartEncrypted *mpe,
camel_stream_flush (filtered_stream);
camel_object_unref (filtered_stream);
camel_object_unref (ciphertext);
+ camel_stream_reset (stream);
decrypted_part = camel_mime_part_new ();
camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (decrypted_part), stream);