Fixes for running pEpEngine tests in debian
authorEdouard Tisserant
Sun, 22 May 2016 15:14:47 +0200
changeset 674a8afa1168b12
parent 673 999e63e9b094
child 675 8305fe701fec
Fixes for running pEpEngine tests in debian
Makefile.conf
asn.1/Makefile
src/pgp_gpg.c
     1.1 --- a/Makefile.conf	Sat May 21 16:37:24 2016 +0200
     1.2 +++ b/Makefile.conf	Sun May 22 15:14:47 2016 +0200
     1.3 @@ -1,6 +1,6 @@
     1.4  BUILD_ON=$(shell uname)
     1.5  BUILD_FOR=$(BUILD_ON)
     1.6 -OPTIMIZE=-g -O0 -std=c99
     1.7 +OPTIMIZE=-g -O0
     1.8  #OPTIMIZE=-O3 -DNDEBUG -std=c99
     1.9  LD=$(CC)
    1.10  #CC=gcc-mp-4.9 -std=c99 -fstrict-aliasing -Wstrict-aliasing=3
     2.1 --- a/asn.1/Makefile	Sat May 21 16:37:24 2016 +0200
     2.2 +++ b/asn.1/Makefile	Sun May 22 15:14:47 2016 +0200
     2.3 @@ -1,5 +1,15 @@
     2.4  include ../Makefile.conf
     2.5  
     2.6 +ifeq ($(BUILD_ON),Linux)
     2.7 +ifeq ($(BUILD_FOR),Linux)
     2.8 +
     2.9 +CC=gcc
    2.10 +CFLAGS?=-fPIC
    2.11 +else
    2.12 +$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    2.13 +endif
    2.14 +endif
    2.15 +
    2.16  ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
    2.17  ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
    2.18  
     3.1 --- a/src/pgp_gpg.c	Sat May 21 16:37:24 2016 +0200
     3.2 +++ b/src/pgp_gpg.c	Sun May 22 15:14:47 2016 +0200
     3.3 @@ -450,6 +450,12 @@
     3.4                          switch (_GPGERR(gpgme_signature->status)) {
     3.5                          case GPG_ERR_NO_ERROR:
     3.6                          {
     3.7 +                            // Some versions of gpg returns signer's 
     3.8 +                            // signing subkey fingerprint instead of
     3.9 +                            // signer's primary key fingerprint.
    3.10 +                            // This is meant to get signer's primary 
    3.11 +                            // key fingerprint, using subkey's.
    3.12 +
    3.13                              gpgme_key_t key;
    3.14                              memset(&key,0,sizeof(key));
    3.15  
    3.16 @@ -465,22 +471,33 @@
    3.17                                  return PEP_OUT_OF_MEMORY;
    3.18                              }
    3.19                              // Primary key is given as the first subkey
    3.20 -                            if (key->subkeys && key->subkeys->fpr && key->subkeys->fpr[0]){
    3.21 +                            if (gpgme_error == GPG_ERR_NO_ERROR &&  
    3.22 +                                key && key->subkeys && key->subkeys->fpr 
    3.23 +                                && key->subkeys->fpr[0])
    3.24 +                            {
    3.25                                  k = stringlist_add(k, key->subkeys->fpr);
    3.26 -                                if (k == NULL) {
    3.27 -                                    free_stringlist(_keylist);
    3.28 -                                    gpg.gpgme_data_release(plain);
    3.29 -                                    gpg.gpgme_data_release(cipher);
    3.30 -                                    free(_buffer);
    3.31 -                                    return PEP_OUT_OF_MEMORY;
    3.32 -                                }
    3.33 +                                gpg.gpgme_key_unref(key);
    3.34                              }
    3.35 -                            else {
    3.36 +                            else if(gpgme_error == GPG_ERR_NOT_OPERATIONAL)
    3.37 +                            {
    3.38 +                                // With some gpgme version, gpgme_get_key fail
    3.39 +                                // with GPG_ERR_NOT_OPERATIONAL, but in that
    3.40 +                                // case fpr is the primary one...
    3.41 +                                k = stringlist_add(k, gpgme_signature->fpr);
    3.42 +                            }
    3.43 +                            else 
    3.44 +                            {
    3.45                                  result = PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH;
    3.46                                  break;
    3.47                              }
    3.48 +                            if (k == NULL) {
    3.49 +                                free_stringlist(_keylist);
    3.50 +                                gpg.gpgme_data_release(plain);
    3.51 +                                gpg.gpgme_data_release(cipher);
    3.52 +                                free(_buffer);
    3.53 +                                return PEP_OUT_OF_MEMORY;
    3.54 +                            }
    3.55  
    3.56 -                            gpg.gpgme_key_unref(key);
    3.57                              break;
    3.58                          }
    3.59                          case GPG_ERR_CERT_REVOKED:
    3.60 @@ -491,6 +508,13 @@
    3.61                          case GPG_ERR_KEY_EXPIRED:
    3.62                          case GPG_ERR_NO_PUBKEY:
    3.63                              k = stringlist_add(k, gpgme_signature->fpr);
    3.64 +                            if (k == NULL) {
    3.65 +                                free_stringlist(_keylist);
    3.66 +                                gpg.gpgme_data_release(plain);
    3.67 +                                gpg.gpgme_data_release(cipher);
    3.68 +                                free(_buffer);
    3.69 +                                return PEP_OUT_OF_MEMORY;
    3.70 +                            }
    3.71                              if (result == PEP_DECRYPTED_AND_VERIFIED)
    3.72                                  result = PEP_DECRYPTED;
    3.73                              break;
    3.74 @@ -650,19 +674,30 @@
    3.75                      return PEP_OUT_OF_MEMORY;
    3.76                  }
    3.77                  // Primary key is given as the first subkey
    3.78 -                if (key->subkeys && key->subkeys->fpr && key->subkeys->fpr[0]){
    3.79 +                if (gpgme_error == GPG_ERR_NO_ERROR &&  
    3.80 +                    key && key->subkeys && key->subkeys->fpr 
    3.81 +                    && key->subkeys->fpr[0])
    3.82 +                {
    3.83                      k = stringlist_add(k, key->subkeys->fpr);
    3.84 -                    if (k == NULL) {
    3.85 -                        free_stringlist(_keylist);
    3.86 -                        gpg.gpgme_data_release(d_text);
    3.87 -                        gpg.gpgme_data_release(d_sig);
    3.88 -                        return PEP_OUT_OF_MEMORY;
    3.89 -                    }
    3.90 +                    gpg.gpgme_key_unref(key);
    3.91 +                }
    3.92 +                else if(gpgme_error == GPG_ERR_NOT_OPERATIONAL)
    3.93 +                {
    3.94 +                    // With some gpgme version, gpgme_get_key fail
    3.95 +                    // with GPG_ERR_NOT_OPERATIONAL, but in that
    3.96 +                    // case fpr is the primary one...
    3.97 +                    k = stringlist_add(k, gpgme_signature->fpr);
    3.98                  }
    3.99                  else {
   3.100                      result = PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH;
   3.101                      break;
   3.102                  }
   3.103 +                if (k == NULL) {
   3.104 +                    free_stringlist(_keylist);
   3.105 +                    gpg.gpgme_data_release(d_text);
   3.106 +                    gpg.gpgme_data_release(d_sig);
   3.107 +                    return PEP_OUT_OF_MEMORY;
   3.108 +                }
   3.109  
   3.110                  gpg.gpgme_key_unref(key);
   3.111