[gmime] Fixed multipart_signed_verify to always set err on error



commit 3c11b5e8113ff313f17f7c7e361f33a7957138d1
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Sun Nov 21 13:05:10 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    |   12 +++++++++---
 3 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index eed2c41..f8bdc23 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 8adeba0..0a82911 100644
--- a/gmime/gmime-multipart-encrypted.c
+++ b/gmime/gmime-multipart-encrypted.c
@@ -291,7 +291,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;
 		}
@@ -305,8 +306,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_literal (err, GMIME_ERROR, GMIME_ERROR_PROTOCOL_ERROR,
+				     "Cannot decrypt multipart/encrypted part: content-type does not match protocol.");
 		
 		g_free (content_type);
 		
@@ -318,8 +319,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_literal (err, GMIME_ERROR, GMIME_ERROR_PROTOCOL_ERROR,
+				     "Cannot decrypt multipart/encrypted part: unexpected content type");
 		
 		return NULL;
 	}
@@ -355,8 +356,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_literal (err, GMIME_ERROR, GMIME_ERROR_PARSE_ERROR,
+				     "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 5cadafe..81034f9 100644
--- a/gmime/gmime-multipart-signed.c
+++ b/gmime/gmime-multipart-signed.c
@@ -343,8 +343,8 @@ g_mime_multipart_signed_verify (GMimeMultipartSigned *mps, GMimeCipherContext *c
 	g_return_val_if_fail (ctx->sign_protocol != NULL, NULL);
 	
 	if (g_mime_multipart_get_count ((GMimeMultipart *) mps) < 2) {
-		g_set_error (err, GMIME_ERROR, GMIME_ERROR_PARSE_ERROR, "%s",
-			     "Cannot verify multipart/signed part due to missing subparts.");
+		g_set_error_literal (err, GMIME_ERROR, GMIME_ERROR_PARSE_ERROR,
+				     "Cannot verify multipart/signed part due to missing subparts.");
 		return NULL;
 	}
 	
@@ -353,8 +353,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;
@@ -365,6 +369,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_literal (err, GMIME_ERROR, GMIME_ERROR_PARSE_ERROR,
+				     "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]