Index: camel/camel-gpg-context.c
===================================================================
--- camel/camel-gpg-context.c	(revision 10035)
+++ camel/camel-gpg-context.c	(working copy)
@@ -65,6 +65,7 @@
 #include "camel-stream-filter.h"
 #include "camel-stream-fs.h"
 #include "camel-stream-mem.h"
+#include "camel-stream-null.h"
 
 #define d(x) 
 
@@ -1112,7 +1113,8 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, Ca
 			goto exception;
 		
 		if (nread > 0) {
-			if (camel_stream_write (gpg->ostream, buffer, (size_t) nread) == -1)
+			ssize_t written = camel_stream_write (gpg->ostream, buffer, (size_t) nread);
+			if (written != nread) 
 				goto exception;
 		} else {
 			gpg->seen_eof1 = TRUE;
@@ -1768,8 +1770,21 @@ gpg_decrypt(CamelCipherContext *context,
 
 	camel_stream_reset(ostream);
 	if (camel_content_type_is(ct, "multipart", "encrypted")) {
+		CamelDataWrapper *dw;
+		CamelStream *null = camel_stream_null_new ();
+
 		/* Multipart encrypted - parse a full mime part */
-		rv = camel_data_wrapper_construct_from_stream((CamelDataWrapper *)opart, ostream);
+		rv = camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)opart, ostream);
+
+		dw = camel_medium_get_content_object ((CamelMedium *)opart);
+		if (!camel_data_wrapper_decode_to_stream (dw, null)) {
+			/* nothing had been decoded from the stream, it doesn't
+			   contain any header, like Content-Type or such, thus
+			   write it as a message body */
+			rv = camel_data_wrapper_construct_from_stream (dw, ostream);
+		}
+
+		camel_object_unref (null);
 	} else {
 		/* Inline signed - raw data (may not be a mime part) */
 		CamelDataWrapper *dw;
Index: camel/ChangeLog
===================================================================
--- camel/ChangeLog	(revision 10035)
+++ camel/ChangeLog	(working copy)
@@ -1,3 +1,13 @@
+2009-02-04  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #386468
+
+	* camel-gpg-context.c: (gpg_decrypt): Put read text from a decode
+	to the message body when parsing of a full mime part fails.
+
+	* camel-gpg-context.c: (gpg_ctx_op_step): Stop as soon as number
+	of written bytes differ from number of read bytes.
+
 2009-02-02  Srinivasa Ragavan  <sragavan@novell.com>
 
 	* camel-db.c: (camel_db_migrate_folder_prepare), (cdb_delete_ids):
