[gmime/gmime-2-4] Fixed multipart_signed_verify to always set err on error



commit 03212c4bcf1ad659f2e7dfeaab47547c1fb00eb4
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Sun Nov 21 12:55:40 2010 -0500

    Fixed multipart_signed_verify to always set err on error
    
    2010-11-21  Jeffrey Stedfast  <fejj novell com>
    
    	Fixes bug #635407.
    
    	* gmime/gmime-multipart-encrypted.c
    	* (g_mime_multipart_encrypted_decrypt):
    	Updated error messages to be more consistent.
    
    	* gmime/gmime-multipart-signed.c
    	* (g_mime_multipart_signed_verify):
    	Make sure to set an error in all cases returning NULL.

 ChangeLog                         |   10 ++++++++++
 gmime/gmime-multipart-encrypted.c |   15 ++++++++-------
 gmime/gmime-multipart-signed.c    |    8 +++++++-
 3 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cb27a5d..43f00ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2010-11-21  Jeffrey Stedfast  <fejj novell com>
 
+	Fixes bug #635407.
+
+	* gmime/gmime-multipart-encrypted.c (g_mime_multipart_encrypted_decrypt):
+	Updated error messages to be more consistent.
+
+	* gmime/gmime-multipart-signed.c (g_mime_multipart_signed_verify):
+	Make sure to set an error in all cases returning NULL.
+
+2010-11-21  Jeffrey Stedfast  <fejj novell com>
+
 	Fixes bug #635405.
 
 	* gmime/gmime-cipher-context.c (g_mime_signer_get_*): These
diff --git a/gmime/gmime-multipart-encrypted.c b/gmime/gmime-multipart-encrypted.c
index e995f45..c1e2cbb 100644
--- a/gmime/gmime-multipart-encrypted.c
+++ b/gmime/gmime-multipart-encrypted.c
@@ -359,7 +359,8 @@ g_mime_multipart_encrypted_decrypt (GMimeMultipartEncrypted *mpe, GMimeCipherCon
 		/* make sure the protocol matches the cipher encrypt protocol */
 		if (g_ascii_strcasecmp (ctx->encrypt_protocol, protocol) != 0) {
 			g_set_error (err, GMIME_ERROR, GMIME_ERROR_PROTOCOL_ERROR,
-				     "Failed to decrypt MIME part: protocol error");
+				     "Cannot decrypt multipart/encrypted part: unsupported encryption protocol '%s'.",
+				     protocol);
 			
 			return NULL;
 		}
@@ -373,8 +374,8 @@ g_mime_multipart_encrypted_decrypt (GMimeMultipartEncrypted *mpe, GMimeCipherCon
 	/* make sure the protocol matches the version part's content-type */
 	content_type = g_mime_content_type_to_string (version->content_type);
 	if (g_ascii_strcasecmp (content_type, protocol) != 0) {
-		g_set_error (err, GMIME_ERROR, GMIME_ERROR_PROTOCOL_ERROR,
-			     "Failed to decrypt MIME part: protocol error");
+		g_set_error (err, GMIME_ERROR, GMIME_ERROR_PROTOCOL_ERROR, "%s",
+			     "Cannot decrypt multipart/encrypted part: content-type does not match protocol.");
 		
 		g_free (content_type);
 		
@@ -386,8 +387,8 @@ g_mime_multipart_encrypted_decrypt (GMimeMultipartEncrypted *mpe, GMimeCipherCon
 	encrypted = g_mime_multipart_get_part (GMIME_MULTIPART (mpe), GMIME_MULTIPART_ENCRYPTED_CONTENT);
 	mime_type = g_mime_object_get_content_type (encrypted);
 	if (!g_mime_content_type_is_type (mime_type, "application", "octet-stream")) {
-		g_set_error (err, GMIME_ERROR, GMIME_ERROR_PROTOCOL_ERROR,
-			     "Failed to decrypt MIME part: unexpected content type");
+		g_set_error (err, GMIME_ERROR, GMIME_ERROR_PROTOCOL_ERROR, "%s",
+			     "Cannot decrypt multipart/encrypted part: unexpected content type");
 		
 		return NULL;
 	}
@@ -423,8 +424,8 @@ g_mime_multipart_encrypted_decrypt (GMimeMultipartEncrypted *mpe, GMimeCipherCon
 	g_object_unref (parser);
 	
 	if (!decrypted) {
-		g_set_error (err, GMIME_ERROR, GMIME_ERROR_PARSE_ERROR,
-			     "Failed to decrypt MIME part: parse error");
+		g_set_error (err, GMIME_ERROR, GMIME_ERROR_PARSE_ERROR, "%s",
+			     "Cannot decrypt multipart/encrypted part: failed to parse decrypted content");
 		
 		g_mime_signature_validity_free (sv);
 		
diff --git a/gmime/gmime-multipart-signed.c b/gmime/gmime-multipart-signed.c
index 16e5963..fffbaa4 100644
--- a/gmime/gmime-multipart-signed.c
+++ b/gmime/gmime-multipart-signed.c
@@ -408,8 +408,12 @@ g_mime_multipart_signed_verify (GMimeMultipartSigned *mps, GMimeCipherContext *c
 	
 	if (protocol) {
 		/* make sure the protocol matches the cipher sign protocol */
-		if (g_ascii_strcasecmp (ctx->sign_protocol, protocol) != 0)
+		if (g_ascii_strcasecmp (ctx->sign_protocol, protocol) != 0) {
+			g_set_error (err, GMIME_ERROR, GMIME_ERROR_PARSE_ERROR,
+				     "Cannot verify multipart/signed part: unsupported signature protocol '%s'.",
+				     protocol);
 			return NULL;
+		}
 	} else {
 		/* *shrug* - I guess just go on as if they match? */
 		protocol = ctx->sign_protocol;
@@ -420,6 +424,8 @@ g_mime_multipart_signed_verify (GMimeMultipartSigned *mps, GMimeCipherContext *c
 	/* make sure the protocol matches the signature content-type */
 	content_type = g_mime_content_type_to_string (signature->content_type);
 	if (g_ascii_strcasecmp (content_type, protocol) != 0) {
+		g_set_error (err, GMIME_ERROR, GMIME_ERROR_PARSE_ERROR, "%s",
+			     "Cannot verify multipart/signed part: signature content-type does not match protocol.");
 		g_free (content_type);
 		
 		return NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]