Fixed misuse of set_own_key krista-local-7-Jan-2020
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Sat, 11 Jan 2020 14:07:06 +0100
branchkrista-local-7-Jan-2020
changeset 432276806e5aebb2
parent 4321 795490894153
child 4323 28b0e2285aa1
Fixed misuse of set_own_key
src/key_reset.c
src/keymanagement.h
     1.1 --- a/src/key_reset.c	Fri Jan 10 02:46:33 2020 +0100
     1.2 +++ b/src/key_reset.c	Sat Jan 11 14:07:06 2020 +0100
     1.3 @@ -490,7 +490,10 @@
     1.4              // ensure that in this case, we end up with a private one,
     1.5              // so talk to vb about this.
     1.6              // Make new key the default    
     1.7 -            curr_ident->fpr = new_fpr;
     1.8 +            
     1.9 +            // This is REQUIRED for set_own_key (see doc)
    1.10 +            curr_ident->fpr = NULL;
    1.11 +            
    1.12              status = set_own_key(session, curr_ident, new_fpr);
    1.13              
    1.14              if (status != PEP_STATUS_OK)
     2.1 --- a/src/keymanagement.h	Fri Jan 10 02:46:33 2020 +0100
     2.2 +++ b/src/keymanagement.h	Sat Jan 11 14:07:06 2020 +0100
     2.3 @@ -370,7 +370,10 @@
     2.4  //      myself() is called by set_own_key() without key generation
     2.5  //      me->flags are ignored
     2.6  //      me->address must not be an alias
     2.7 -//      me->fpr will be ignored and replaced by fpr
     2.8 +//      me->fpr will be ignored and replaced by fpr, but
     2.9 +//      caller MUST surrender ownership of the me->fpr reference, because 
    2.10 +//      it may be freed and replaced within the myself call. caller owns 
    2.11 +//      me->fpr memory again upon return.
    2.12  
    2.13  DYNAMIC_API PEP_STATUS set_own_key(
    2.14         PEP_SESSION session,