cleanup sync
authorVolker Birk <vb@pep-project.org>
Fri, 31 Jan 2020 14:28:12 +0100
branchsync
changeset 4389d815710511c8
parent 4388 dacd99febde5
child 4390 64a2a246abf5
cleanup
src/keymanagement.c
sync/cond_act_sync.yml2
     1.1 --- a/src/keymanagement.c	Fri Jan 31 14:17:25 2020 +0100
     1.2 +++ b/src/keymanagement.c	Fri Jan 31 14:28:12 2020 +0100
     1.3 @@ -1898,12 +1898,12 @@
     1.4      assert(!EMPTYSTR(me->user_id));
     1.5      assert(!EMPTYSTR(me->username));
     1.6  
     1.7 -    // deliver a copy
     1.8 -    assert(me->fpr != fpr);
     1.9 +    if (!session || !me || EMPTYSTR(fpr) || EMPTYSTR(me->address) ||
    1.10 +            EMPTYSTR(me->user_id) || EMPTYSTR(me->username))
    1.11 +        return PEP_ILLEGAL_VALUE;
    1.12  
    1.13 -    if (!session || !me || EMPTYSTR(fpr) || EMPTYSTR(me->address) ||
    1.14 -            EMPTYSTR(me->user_id) || EMPTYSTR(me->username) || me->fpr == fpr)
    1.15 -        return PEP_ILLEGAL_VALUE;
    1.16 +    if (me->fpr == fpr)
    1.17 +        me->fpr = NULL;
    1.18  
    1.19      status = _myself(session, me, false, true, false);
    1.20      // we do not need a valid key but dislike other errors
     2.1 --- a/sync/cond_act_sync.yml2	Fri Jan 31 14:17:25 2020 +0100
     2.2 +++ b/sync/cond_act_sync.yml2	Fri Jan 31 14:28:12 2020 +0100
     2.3 @@ -399,13 +399,9 @@
     2.4      }
     2.5  
     2.6      identity_list *oil = session->sync_state.own.identities;
     2.7 -    char *fpr = NULL;
     2.8  
     2.9      // BUG: this should be a transaction and been rolled back completely on error
    2.10      for (identity_list *_il = il; _il && _il->ident; _il = _il->next) {
    2.11 -        if (fpr)
    2.12 -            free(fpr);
    2.13 -
    2.14          bool found = false;
    2.15          status = _have_identity_in(oil, _il->ident, &found);
    2.16          if (status)
    2.17 @@ -414,20 +410,12 @@
    2.18          if (!found) {
    2.19              _il->ident->me = true;
    2.20  
    2.21 -            fpr = strdup(_il->ident->fpr);
    2.22 -            assert(fpr);
    2.23 -            if (!fpr) {
    2.24 -                status = PEP_OUT_OF_MEMORY;
    2.25 -                break;
    2.26 -            }
    2.27 -
    2.28 -            status = set_own_key(session, _il->ident, fpr);
    2.29 +            status = set_own_key(session, _il->ident, _il->ident->fpr);
    2.30              if (status)
    2.31                  break;
    2.32          }
    2.33      }
    2.34  
    2.35 -    free(fpr);
    2.36      free(user_id);
    2.37      free_identity_list(il);
    2.38  ||
    2.39 @@ -475,19 +463,7 @@
    2.40      }
    2.41  
    2.42      for (identity_list *_il = il; _il && _il->ident ; _il = _il->next) {
    2.43 -        // replace partner's user_id with own user_id
    2.44 -        free(_il->ident->user_id);
    2.45 -        _il->ident->user_id = strdup(user_id);
    2.46 -        assert(_il->ident->user_id);
    2.47 -        if (!_il->ident->user_id) {
    2.48 -            free_identity_list(il);
    2.49 -            free(user_id);
    2.50 -            return PEP_OUT_OF_MEMORY;
    2.51 -        }
    2.52 -
    2.53 -        const char *own_key = _il->ident->fpr;
    2.54 -        _il->ident->fpr = NULL;
    2.55 -        status = set_own_key(session, _il->ident, own_key);
    2.56 +        status = set_own_key(session, _il->ident, _il->ident->fpr);
    2.57          if (status) {
    2.58              free_identity_list(il);
    2.59              free(user_id);