[gmime] Implemented support for ERRSIG return codes



commit 4144b8690890ab1864a0f9e89c62dcf4920d1a3d
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Sat Jan 22 15:36:36 2011 -0500

    Implemented support for ERRSIG return codes
    
    2011-01-22  Jeffrey Stedfast  <fejj novell com>
    
    	* gmime/gmime-gpg-context.c (gpg_ctx_parse_signer_info): Parse
    	the ERRSIG's return code, fixes bug #638605.
    
    	* gmime/gmime-crypto-context.h: Added UNSUPP_ALGO error value.

 ChangeLog                    |    7 +++++++
 gmime/gmime-crypto-context.h |    7 ++++---
 gmime/gmime-gpg-context.c    |   17 ++++++++++-------
 3 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 20053c8..5e6cd01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-01-22  Jeffrey Stedfast  <fejj novell com>
 
+	* gmime/gmime-gpg-context.c (gpg_ctx_parse_signer_info): Parse the
+	ERRSIG's return code, fixes bug #638605.
+
+	* gmime/gmime-crypto-context.h: Added UNSUPP_ALGO error value.
+
+2011-01-22  Jeffrey Stedfast  <fejj novell com>
+
 	* gmime/gmime-stream-mem.c (stream_write): Correctly calculate the
 	end boundary of the stream when bound_end is -1.
 
diff --git a/gmime/gmime-crypto-context.h b/gmime/gmime-crypto-context.h
index b6d57ad..da675e4 100644
--- a/gmime/gmime-crypto-context.h
+++ b/gmime/gmime-crypto-context.h
@@ -260,7 +260,8 @@ typedef enum {
 	GMIME_SIGNER_ERROR_EXPSIG      = (1 << 0),  /* expired signature */
 	GMIME_SIGNER_ERROR_NO_PUBKEY   = (1 << 1),  /* no public key */
 	GMIME_SIGNER_ERROR_EXPKEYSIG   = (1 << 2),  /* expired key */
-	GMIME_SIGNER_ERROR_REVKEYSIG   = (1 << 3)   /* revoked key */
+	GMIME_SIGNER_ERROR_REVKEYSIG   = (1 << 3),  /* revoked key */
+	GMIME_SIGNER_ERROR_UNSUPP_ALGO = (1 << 4)   /* unsupported algorithm */
 } GMimeSignerError;
 
 
@@ -289,9 +290,9 @@ typedef enum {
 struct _GMimeSigner {
 	GMimeSigner *next;
 	unsigned int status:2;    /* GMimeSignerStatus */
-	unsigned int errors:4;    /* bitfield of GMimeSignerError's */
+	unsigned int errors:5;    /* bitfield of GMimeSignerError's */
 	unsigned int trust:3;     /* GMimeSignerTrust */
-	unsigned int unused:21;   /* unused expansion bits */
+	unsigned int unused:20;   /* unused expansion bits */
 	GMimeCryptoPubKeyAlgo pubkey_algo;
 	GMimeCryptoHash hash_algo;
 	char *issuer_serial;
diff --git a/gmime/gmime-gpg-context.c b/gmime/gmime-gpg-context.c
index 82dba35..886c5b4 100644
--- a/gmime/gmime-gpg-context.c
+++ b/gmime/gmime-gpg-context.c
@@ -827,6 +827,7 @@ static void
 gpg_ctx_parse_signer_info (struct _GpgCtx *gpg, char *status)
 {
 	GMimeSigner *signer;
+	char *inend;
 	
 	if (!strncmp (status, "SIG_ID ", 7)) {
 		/* not sure if this contains anything we care about... */
@@ -875,10 +876,15 @@ gpg_ctx_parse_signer_info (struct _GpgCtx *gpg, char *status)
 		status = next_token (status, NULL);
 		
 		/* get the signature expiration date (or 0 for never) */
-		signer->sig_expires = strtoul (status, NULL, 10);
-		status = next_token (status, NULL);
+		signer->sig_expires = strtoul (status, &inend, 10);
+		status = inend + 1;
 		
-		/* the last token is the 'rc' which we don't care about */
+		/* get the return code */
+		switch (strtol (status, NULL, 10)) {
+		case 4: signer->errors |= GMIME_SIGNER_ERROR_UNSUPP_ALGO; break;
+		case 9: signer->errors |= GMIME_SIGNER_ERROR_NO_PUBKEY; break;
+		default: break;
+		}
 	} else if (!strncmp (status, "NO_PUBKEY ", 10)) {
 		/* the only token is the keyid, but we've already got it */
 		gpg->signer->errors |= GMIME_SIGNER_ERROR_NO_PUBKEY;
@@ -890,11 +896,8 @@ gpg_ctx_parse_signer_info (struct _GpgCtx *gpg, char *status)
 	} else if (!strncmp (status, "REVKEYSIG", 9)) {
 		gpg->signer->errors |= GMIME_SIGNER_ERROR_REVKEYSIG;
 	} else if (!strncmp (status, "VALIDSIG ", 9)) {
-		char *inend;
-		
-		status += 9;
-		
 		signer = gpg->signer;
+		status += 9;
 		
 		/* the first token is the fingerprint */
 		status = next_token (status, &signer->fingerprint);



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