ENGINE-129: update_identity now properly returns an ID with an empty fpr string when no key can be elected because none are in the keyring ENGINE-129
authorKrista Grothoff <krista@pep-project.org>
Thu, 27 Oct 2016 21:43:59 +0200
branchENGINE-129
changeset 134289f45a5a9ae2
parent 1341 a54396ccb460
child 1343 59f014327d4a
ENGINE-129: update_identity now properly returns an ID with an empty fpr string when no key can be elected because none are in the keyring
src/keymanagement.c
     1.1 --- a/src/keymanagement.c	Wed Oct 26 18:34:58 2016 +0200
     1.2 +++ b/src/keymanagement.c	Thu Oct 27 21:43:59 2016 +0200
     1.3 @@ -24,7 +24,7 @@
     1.4  {
     1.5      PEP_STATUS status;
     1.6      stringlist_t *keylist;
     1.7 -    char *_fpr = NULL;
     1.8 +    char *_fpr = "";
     1.9      identity->comm_type = PEP_ct_unknown;
    1.10  
    1.11      status = find_keys(session, identity->address, &keylist);
    1.12 @@ -59,15 +59,16 @@
    1.13          }
    1.14      }
    1.15  
    1.16 -    if (_fpr) {
    1.17 -        free(identity->fpr);
    1.18 +    
    1.19 +//    if (_fpr) {
    1.20 +    free(identity->fpr);
    1.21  
    1.22 -        identity->fpr = strdup(_fpr);
    1.23 -        if (identity->fpr == NULL) {
    1.24 -            free_stringlist(keylist);
    1.25 -            return PEP_OUT_OF_MEMORY;
    1.26 -        }
    1.27 +    identity->fpr = strdup(_fpr);
    1.28 +    if (identity->fpr == NULL) {
    1.29 +        free_stringlist(keylist);
    1.30 +        return PEP_OUT_OF_MEMORY;
    1.31      }
    1.32 +//    }
    1.33      free_stringlist(keylist);
    1.34      return PEP_STATUS_OK;
    1.35  }
    1.36 @@ -137,7 +138,7 @@
    1.37          bool dont_use_fpr = true;
    1.38  
    1.39          /* if we have a stored_identity fpr */
    1.40 -        if (!EMPTYSTR(stored_identity->fpr)) {
    1.41 +        if (!EMPTYSTR(stored_identity->fpr) && !EMPTYSTR(temp_id->fpr)) {
    1.42              status = blacklist_is_listed(session, stored_identity->fpr, &dont_use_fpr);
    1.43              if (status != PEP_STATUS_OK)
    1.44                  dont_use_fpr = true;