ENGINE-183 more fixes ENGINE-183
authorEdouard Tisserant <edouard@pep-project.org>
Mon, 08 May 2017 17:55:33 +0200
branchENGINE-183
changeset 1760f691b9603e8b
parent 1757 ad2ddc7c88a5
child 1761 6e6a47a20657
child 1762 584013f25143
ENGINE-183 more fixes
src/keymanagement.c
src/pEpEngine.c
src/pgp_gpg.c
     1.1 --- a/src/keymanagement.c	Mon May 08 15:41:24 2017 +0200
     1.2 +++ b/src/keymanagement.c	Mon May 08 17:55:33 2017 +0200
     1.3 @@ -996,7 +996,7 @@
     1.4      return _own_keys_retrieve(session, keylist, 0);
     1.5  }
     1.6  
     1.7 -// TODO: Unused for now, but should be used when sync receive old keys (ENGINE-145)
     1.8 +// FIXME: should it be be used when sync receive old keys ? (ENGINE-145)
     1.9  DYNAMIC_API PEP_STATUS set_own_key(
    1.10         PEP_SESSION session,
    1.11         const char *address,
    1.12 @@ -1006,12 +1006,12 @@
    1.13      PEP_STATUS status = PEP_STATUS_OK;
    1.14      
    1.15      assert(session &&
    1.16 -           address && address[0] &&
    1.17 +           address &&
    1.18             fpr && fpr[0]
    1.19            );
    1.20      
    1.21      if (!(session &&
    1.22 -          address && address[0] &&
    1.23 +          address &&
    1.24            fpr && fpr[0]
    1.25           ))
    1.26          return PEP_ILLEGAL_VALUE;
     2.1 --- a/src/pEpEngine.c	Mon May 08 15:41:24 2017 +0200
     2.2 +++ b/src/pEpEngine.c	Mon May 08 17:55:33 2017 +0200
     2.3 @@ -667,7 +667,7 @@
     2.4          
     2.5          stringlist_t *keylist = NULL;
     2.6  
     2.7 -        status = find_private_keys(_session, "", &keylist);
     2.8 +        status = find_private_keys(_session, NULL, &keylist);
     2.9          assert(status != PEP_OUT_OF_MEMORY);
    2.10          if (status == PEP_OUT_OF_MEMORY)
    2.11              return PEP_OUT_OF_MEMORY;
    2.12 @@ -2273,8 +2273,8 @@
    2.13  
    2.14  PEP_STATUS find_private_keys(PEP_SESSION session, const char* pattern,
    2.15                               stringlist_t **keylist) {
    2.16 -    assert(session && pattern && keylist);
    2.17 -    if (!(session && pattern && keylist))
    2.18 +    assert(session && keylist);
    2.19 +    if (!(session && keylist))
    2.20          return PEP_ILLEGAL_VALUE;
    2.21      
    2.22      return session->cryptotech[PEP_crypt_OpenPGP].find_private_keys(session, pattern,
     3.1 --- a/src/pgp_gpg.c	Mon May 08 15:41:24 2017 +0200
     3.2 +++ b/src/pgp_gpg.c	Mon May 08 17:55:33 2017 +0200
     3.3 @@ -1547,7 +1547,6 @@
     3.4      gpgme_key_t key;
     3.5  
     3.6      assert(session);
     3.7 -    assert(pattern);
     3.8      assert(keylist);
     3.9  
    3.10      *keylist = NULL;
    3.11 @@ -1584,7 +1583,9 @@
    3.12                  gpgme_user_id_t kuid = key->uids;
    3.13                  // check that at least one uid's email matches pattern exactly
    3.14                  while(kuid) {
    3.15 -                    if(kuid->email && strcmp(kuid->email, pattern) == 0){
    3.16 +                    if((pattern && kuid->email && strcmp(kuid->email, pattern) == 0) ||
    3.17 +                       pattern == NULL /* match all */ )
    3.18 +                    { 
    3.19                          char *fpr = key->subkeys->fpr;
    3.20                          assert(fpr);
    3.21                          _k = stringlist_add(_k, fpr);