aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl-Heinz Zimmer <[email protected]>2002-07-03 15:43:41 +0000
committerKarl-Heinz Zimmer <[email protected]>2002-07-03 15:43:41 +0000
commite3e127d4a8cf5b1d6b8593ffd73fe93b1c66df9d (patch)
treec82c4c3f730dbf219db1896dff29a675571acadb
parent* gpgmeplug.c (nextCertificate): Actually free the entire array (diff)
downloadgpgme-e3e127d4a8cf5b1d6b8593ffd73fe93b1c66df9d.tar.gz
gpgme-e3e127d4a8cf5b1d6b8593ffd73fe93b1c66df9d.zip
fixing bug #1154
Diffstat (limited to '')
-rw-r--r--gpgmeplug/gpgmeplug.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/gpgmeplug/gpgmeplug.c b/gpgmeplug/gpgmeplug.c
index 72466a97..7622fda6 100644
--- a/gpgmeplug/gpgmeplug.c
+++ b/gpgmeplug/gpgmeplug.c
@@ -1453,14 +1453,65 @@ bool encryptMessage( const char* cleartext,
err = gpgme_op_encrypt (ctx, rset, gPlaintext, gCiphertext );
if( err ) {
- fprintf( stderr, "\ngpgme_op_encrypt() returned this error code: %i\n\n", err );
+ fprintf( stderr, "\ngpgme_op_encrypt() returned this error code: %i\n", err );
if( errId )
*errId = err;
if( errTxt ) {
const char* _errTxt = gpgme_strerror( err );
- *errTxt = malloc( strlen( _errTxt ) + 1 );
- if( *errTxt )
+ *errTxt = malloc( strlen( _errTxt ) + 100 ); // leave room for reason string
+ if( *errTxt ) {
+ char* opInfo;
strcpy(*errTxt, _errTxt );
+ opInfo = gpgme_get_op_info(ctx, 0);
+ if( NULL != opInfo && *opInfo ){
+ const int opLen = strlen( opInfo );
+ const int reasonLen = 8;
+ char reason[ 1+reasonLen ];
+ char* pos1;
+ strcpy( reason, "<reason>" );
+ pos1 = strstr( opInfo, reason );
+ if( NULL != pos1 &&
+ opLen > reasonLen + (pos1 - opInfo) ){
+ char* pos2;
+ pos1 += reasonLen;
+ pos2 = strchr( pos1, '<' );
+ if( NULL != pos2 &&
+ pos1 < pos2 ){
+ long int reasonId;
+ strcat( *errTxt, " - " );
+ *pos2 = '\0';
+ fprintf( stderr, " and this reason code: %s\n\n", pos1 );
+ reasonId = strtol( pos1, NULL, 10 );
+ switch( reasonId ) {
+ case 0: strcat( *errTxt, "No specific reason given" );
+ break;
+ case 1: strcat( *errTxt, "Not Found" );
+ break;
+ case 2: strcat( *errTxt, "Ambigious specification" );
+ break;
+ case 3: strcat( *errTxt, "Key can't be used for operation" );
+ break;
+ case 4: strcat( *errTxt, "Key has been revoked" );
+ break;
+ case 5: strcat( *errTxt, "Key has expired" );
+ break;
+ case 6: strcat( *errTxt, "No CRL known for certificate" );
+ break;
+ case 7: strcat( *errTxt, "No current CRL available" );
+ break;
+ case 8: strcat( *errTxt, "Contraints not matched" );
+ break;
+ default: {
+ strcat( *errTxt, "Extended error Id: #" );
+ strcat( *errTxt, pos1 );
+ }
+ }
+ *pos2 = '<';
+ }
+ }
+ free( opInfo );
+ }
+ }
}
}