aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-07-13 07:14:16 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-07-13 07:14:16 +0800
commit47f459e2108ca1cd8b37be7114dc8efaf1581b78 (patch)
treef6d1bcfd0781b84324b9e6b50552968ca7285eca /camel
parentefdafd9d878dc8a5c27b13e18b2d08cb52aa066b (diff)
downloadgsoc2013-evolution-47f459e2108ca1cd8b37be7114dc8efaf1581b78.tar
gsoc2013-evolution-47f459e2108ca1cd8b37be7114dc8efaf1581b78.tar.gz
gsoc2013-evolution-47f459e2108ca1cd8b37be7114dc8efaf1581b78.tar.bz2
gsoc2013-evolution-47f459e2108ca1cd8b37be7114dc8efaf1581b78.tar.lz
gsoc2013-evolution-47f459e2108ca1cd8b37be7114dc8efaf1581b78.tar.xz
gsoc2013-evolution-47f459e2108ca1cd8b37be7114dc8efaf1581b78.tar.zst
gsoc2013-evolution-47f459e2108ca1cd8b37be7114dc8efaf1581b78.zip
On error, do not unref the parts gotten using camel_multipart_get_part()
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 ;-) svn path=/trunk/; revision=17445
Diffstat (limited to 'camel')
-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);