rem: this_info.creation_time = (tm*)malloc( sizeof( struct tm ) ); if ( this_info.creation_time ) { struct tm * ctime_val = localtime( (time_t*)&signature->timestamp ); memcpy( this_info.creation_time, ctime_val, sizeof( struct tm ) );
add: if ( signature->timestamp ) { this_info.creation_time = (tm*)malloc( sizeof( struct tm ) ); if ( this_info.creation_time ) { struct tm * ctime_val = localtime( (time_t*)&signature->timestamp ); memcpy( this_info.creation_time, ctime_val, sizeof( struct tm ) ); }
context: void obtain_signature_information( gpgme_ctx_t ctx,                                   gpgme_sig_stat_t & overallStatus,                                   struct CryptPlug::SignatureMetaData* sigmeta,                                   char** attrOrder,                                   const char* unknownAttrsHandling,                                   bool * signatureFound=0 ){  gpgme_error_t err;  unsigned long sumGPGME;  SigStatusFlags sumPlug;  struct CryptPlug::DnPair* a;  int sig_idx=0;  assert( ctx );  assert( sigmeta );  sigmeta->extended_info = 0;  gpgme_verify_result_t result = gpgme_op_verify_result( ctx );  if ( !result )    return;  for ( gpgme_signature_t signature = result->signatures ; signature ; signature = signature->next, ++sig_idx ) {    void* alloc_return = realloc( sigmeta->extended_info,                                  sizeof( CryptPlug::SignatureMetaDataExtendedInfo )                                  * ( sig_idx + 1 ) );    if ( !alloc_return )      break;    sigmeta->extended_info = (CryptPlug::SignatureMetaDataExtendedInfo*)alloc_return;    /* shorthand notation :) */    CryptPlug::SignatureMetaDataExtendedInfo & this_info = sigmeta->extended_info[sig_idx];    /* clear the data area */    memset( &this_info, 0, sizeof (CryptPlug::SignatureMetaDataExtendedInfo) );    /* the creation time */    this_info.creation_time = (tm*)malloc( sizeof( struct tm ) );    if ( this_info.creation_time ) {      struct tm * ctime_val = localtime( (time_t*)&signature->timestamp );      memcpy( this_info.creation_time,	      ctime_val, sizeof( struct tm ) );    }    /* the extended signature verification status */    sumGPGME = signature->summary;    fprintf( stderr, "gpgmeplug checkMessageSignature status flags: %lX\n", sumGPGME );    /* translate GPGME status flags to common CryptPlug status flags */    sumPlug = 0;#define convert(X) if ( sumGPGME & GPGME_SIGSUM_##X ) sumPlug |= SigStat_##X    convert(VALID);    convert(GREEN);    convert(RED);    convert(KEY_REVOKED);    convert(KEY_EXPIRED);    convert(SIG_EXPIRED);    convert(KEY_MISSING);    convert(CRL_MISSING);    convert(CRL_TOO_OLD);    convert(BAD_POLICY);    convert(SYS_ERROR);#undef convert    if( sumGPGME && !sumPlug )      sumPlug = SigStat_NUMERICAL_CODE | sumGPGME;    this_info.sigStatusFlags = sumPlug;    /* extract finger print */    if ( signature->fpr )      storeNewCharPtr( &this_info.fingerprint, signature->fpr );    /* validity */    this_info.validity = GPGME_VALIDITY_UNKNOWN;    /* sig key data */    gpgme_key_t key = 0;    // PENDING(marc) if this is deprecated, how shall we get at all    // the infos below?    err = gpgme_get_sig_key (ctx, sig_idx, &key);    if ( !err && key ) {      const char* attr_string;      unsigned long attr_ulong;      /* extract key identidy */      attr_string = key->subkeys ? key->subkeys->keyid : 0 ;      if ( attr_string )	storeNewCharPtr( &this_info.keyid, attr_string );      /* pubkey algorithm */      attr_string = key->subkeys ? gpgme_pubkey_algo_name( key->subkeys->pubkey_algo ) : 0 ;      if (attr_string != 0)	storeNewCharPtr( &this_info.algo, attr_string );      attr_ulong = key->subkeys ? key->subkeys->pubkey_algo : 0 ;      this_info.algo_num = attr_ulong;      /* extract key validity */      attr_ulong = key->uids ? key->uids->validity : 0 ;      this_info.validity = attr_ulong;      /* extract user id, according to the documentation it's representable       * as a number, but it seems that it also has a string representation       */      attr_string = key->uids ? key->uids->uid : 0 ;      if (attr_string != 0) {        a = parse_dn( (const unsigned char*)attr_string );        this_info.userid = reorder_dn( a, attrOrder, unknownAttrsHandling );      }      attr_ulong = 0;      this_info.userid_num = attr_ulong;      /* extract the length */      this_info.keylen = key->subkeys ? key->subkeys->length : 0 ;      /* extract the creation time of the key */      attr_ulong = key->subkeys ? key->subkeys->timestamp : 0 ;      this_info.key_created = attr_ulong;      /* extract the expiration time of the key */      attr_ulong = key->subkeys ? key->subkeys->expires : 0 ;      this_info.key_expires = attr_ulong;      /* extract user name */      attr_string = key->uids ? key->uids->name : 0 ;      if (attr_string != 0) {        a = parse_dn( (const unsigned char*)attr_string );        this_info.name = reorder_dn( a, attrOrder, unknownAttrsHandling );      }      /* extract email(s) */      this_info.emailCount = 0;      this_info.emailList = 0;      for ( gpgme_user_id_t uid = key->uids ; uid ; uid = uid->next ) {        attr_string = uid->email;        if ( attr_string && *attr_string) {          fprintf( stderr, "gpgmeplug checkMessageSignature found email: %s\n", attr_string );          if( !this_info.emailCount )            alloc_return = malloc( sizeof( char*) );          else            alloc_return = realloc( this_info.emailList,                  sizeof( char*)                  * (this_info.emailCount + 1) );          if( alloc_return ) {            this_info.emailList = (char**)alloc_return;            storeNewCharPtr( &( this_info.emailList[ this_info.emailCount ] ),                attr_string );            ++this_info.emailCount;          }        }      }      if( !this_info.emailCount )	fprintf( stderr, "gpgmeplug checkMessageSignature found NO EMAIL\n" );      /* extract the comment */      attr_string = key->uids ? key->uids->comment : 0 ;      if (attr_string != 0)	storeNewCharPtr( &this_info.comment, attr_string );    }    gpgme_sig_stat_t status = sig_stat_from_status( signature->status );    const char* sig_status = sig_status_to_string( status );    storeNewCharPtr( &this_info.status_text, sig_status );  }  sigmeta->extended_info_count = sig_idx;  overallStatus = intersect_stati( result->signatures );  sigmeta->status_code = overallStatus;  storeNewCharPtr( &sigmeta->status, sig_status_to_string( overallStatus ) );  if ( signatureFound )    *signatureFound = ( overallStatus != GPGME_SIG_STAT_NONE );}