...
authorEdouard Tisserant
Tue, 15 Mar 2016 14:16:08 +0100
changeset 505efce4b415d22
parent 504 d39474ff2e91
child 508 a4710d4c678a
...
src/pgp_gpg.c
     1.1 --- a/src/pgp_gpg.c	Tue Mar 15 13:37:52 2016 +0100
     1.2 +++ b/src/pgp_gpg.c	Tue Mar 15 14:16:08 2016 +0100
     1.3 @@ -444,8 +444,40 @@
     1.4                      do {
     1.5                          switch (_GPGERR(gpgme_signature->status)) {
     1.6                          case GPG_ERR_NO_ERROR:
     1.7 -                            k = stringlist_add(k, gpgme_signature->fpr);
     1.8 +                        {
     1.9 +                            gpgme_key_t key;
    1.10 +                            memset(&key,0,sizeof(key));
    1.11 +
    1.12 +                            gpgme_error = gpg.gpgme_get_key(session->ctx,
    1.13 +                                gpgme_signature->fpr, &key, 0);
    1.14 +                            gpgme_error = _GPGERR(gpgme_error);
    1.15 +                            assert(gpgme_error != GPG_ERR_ENOMEM);
    1.16 +                            if (gpgme_error == GPG_ERR_ENOMEM) {
    1.17 +                                free_stringlist(_keylist);
    1.18 +                                gpg.gpgme_data_release(plain);
    1.19 +                                gpg.gpgme_data_release(cipher);
    1.20 +                                free(_buffer);
    1.21 +                                return PEP_OUT_OF_MEMORY;
    1.22 +                            }
    1.23 +                            // Primary key is given as the first subkey
    1.24 +                            if (key->subkeys && key->subkeys->fpr && key->subkeys->fpr[0]){
    1.25 +                                k = stringlist_add(k, key->subkeys->fpr);
    1.26 +                                if (k == NULL) {
    1.27 +                                    free_stringlist(_keylist);
    1.28 +                                    gpg.gpgme_data_release(plain);
    1.29 +                                    gpg.gpgme_data_release(cipher);
    1.30 +                                    free(_buffer);
    1.31 +                                    return PEP_OUT_OF_MEMORY;
    1.32 +                                }
    1.33 +                            }
    1.34 +                            else {
    1.35 +                                result = PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH;
    1.36 +                                break;
    1.37 +                            }
    1.38 +
    1.39 +                            gpg.gpgme_key_unref(key);
    1.40                              break;
    1.41 +                        }
    1.42                          case GPG_ERR_CERT_REVOKED:
    1.43                          case GPG_ERR_BAD_SIGNATURE:
    1.44                              result = PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH;
    1.45 @@ -608,6 +640,8 @@
    1.46                  assert(gpgme_error != GPG_ERR_ENOMEM);
    1.47                  if (gpgme_error == GPG_ERR_ENOMEM) {
    1.48                      free_stringlist(_keylist);
    1.49 +                    gpg.gpgme_data_release(d_text);
    1.50 +                    gpg.gpgme_data_release(d_sig);
    1.51                      return PEP_OUT_OF_MEMORY;
    1.52                  }
    1.53                  // Primary key is given as the first subkey