aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl-Heinz Zimmer <[email protected]>2002-10-31 16:30:45 +0000
committerKarl-Heinz Zimmer <[email protected]>2002-10-31 16:30:45 +0000
commite4a6f97d5e9c5a6139fa685100771d20091b790b (patch)
tree1d4d39b1bbac40fde5264f43330b78f6778a42e7
parentAdd error checking for isEmailInCertificate being called with invalid fingerp... (diff)
downloadgpgme-e4a6f97d5e9c5a6139fa685100771d20091b790b.tar.gz
gpgme-e4a6f97d5e9c5a6139fa685100771d20091b790b.zip
Adding support for email addresses includes in '<' and '>'.
-rw-r--r--gpgmeplug/gpgmeplug.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/gpgmeplug/gpgmeplug.c b/gpgmeplug/gpgmeplug.c
index 15f3fb96..8391593c 100644
--- a/gpgmeplug/gpgmeplug.c
+++ b/gpgmeplug/gpgmeplug.c
@@ -457,16 +457,22 @@ bool warnNoCertificate()
bool isEmailInCertificate( const char* email, const char* fingerprint )
{
bool bOk = false;
- if( fingerprint ){
+ if( searchEmail && fingerprint ){
GpgmeCtx ctx;
GpgmeError err;
GpgmeKey rKey;
int UID_idx;
const char* attr_string;
- int fprLen = strlen( fingerprint );
+ const char* email = searchEmail;
+ int emailLen = strlen( email );
int emailCount = 0;
- fprintf( stderr, "gpgmeplug isEmailInCertificate looking for fingerprint %s\n", fingerprint );
+ if (email && *email == '<'){
+ ++email;
+ emailLen -= 2;
+ }
+
+ fprintf( stderr, "gpgmeplug isEmailInCertificate looking address %s\nin certificate with fingerprint %s\n", email, fingerprint );
gpgme_new( &ctx );
gpgme_set_protocol( ctx, GPGMEPLUG_PROTOCOL );
@@ -478,24 +484,21 @@ bool isEmailInCertificate( const char* email, const char* fingerprint )
if ( GPGME_No_Error == err ) {
/* extract email(s) */
for( UID_idx = 0;
- (attr_string = gpgme_key_get_string_attr(
- rKey, GPGME_ATTR_EMAIL, 0, UID_idx ) );
- ++UID_idx ){
- if (attr_string && *attr_string) {
- ++emailCount;
- fprintf( stderr, "gpgmeplug isEmailInCertificate found email: %s\n", attr_string );
- if( 0 == strcasecmp(attr_string, email) ){
- bOk = true;
- break;
- }else{
- attr_string = gpgme_key_get_string_attr(
- rKey, GPGME_ATTR_USERID, 0, UID_idx );
- if (attr_string && *attr_string == '<'){
- ++attr_string;
- if( 0 == strncasecmp(attr_string, email, fprLen) ){
- bOk = true;
- break;
- }
+ (attr_string = gpgme_key_get_string_attr(
+ rKey, GPGME_ATTR_EMAIL, 0, UID_idx));
+ ++UID_idx ){
+ if( !attr_string || !*attr_string )
+ attr_string = gpgme_key_get_string_attr(
+ rKey, GPGME_ATTR_USERID, 0, UID_idx );
+ if( attr_string ){
+ if( *attr_string == '<' )
+ ++attr_string;
+ if( *attr_string ){
+ ++emailCount;
+ fprintf( stderr, "gpgmeplug isEmailInCertificate found email: %s\n", attr_string );
+ if( 0 == strncasecmp(attr_string, email, emailLen) ){
+ bOk = true;
+ break;
}
}
}
@@ -513,7 +516,10 @@ bool isEmailInCertificate( const char* email, const char* fingerprint )
}
gpgme_release( ctx );
}else{
- fprintf( stderr, "gpgmeplug isEmailInCertificate called with parameter FINGERPRINT being EMPTY\n" );
+ if( searchEmail )
+ fprintf( stderr, "gpgmeplug isEmailInCertificate called with parameter FINGERPRINT being EMPTY\n" );
+ else
+ fprintf( stderr, "gpgmeplug isEmailInCertificate called with parameter EMAIL being EMPTY\n" );
}
return bOk;
}