IOSAD-92 treat decrypt_message()'s keylist is inout for extraKeys
authorDirk Zimmermann <dirk@pep-project.org>
Tue, 08 May 2018 07:02:46 +0200
changeset 6050c6fc87450e5
parent 604 1af0cfd35a84
child 606 a0a4854da6ce
IOSAD-92 treat decrypt_message()'s keylist is inout for extraKeys
pEpObjCAdapter/PEPInternalSession.m
     1.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Thu May 03 15:49:46 2018 +0200
     1.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Tue May 08 07:02:46 2018 +0200
     1.3 @@ -119,20 +119,24 @@
     1.4  
     1.5      message *_src = PEP_messageDictToStruct(messageDict);
     1.6      message *_dst = NULL;
     1.7 -    stringlist_t *_keys = NULL;
     1.8 +    stringlist_t *theKeys = NULL;
     1.9      PEP_decrypt_flags theFlags = 0;
    1.10  
    1.11      if (flags) {
    1.12          theFlags = *flags;
    1.13      }
    1.14  
    1.15 +    if (extraKeys && [*extraKeys count]) {
    1.16 +        theKeys = PEP_arrayToStringlist(*extraKeys);
    1.17 +    }
    1.18 +
    1.19      PEP_rating internalRating = PEP_rating_undefined;
    1.20  
    1.21      [self lockWrite];
    1.22      PEP_STATUS theStatus = decrypt_message(_session,
    1.23                                             _src,
    1.24                                             &_dst,
    1.25 -                                           &_keys,
    1.26 +                                           &theKeys,
    1.27                                             &internalRating,
    1.28                                             &theFlags);
    1.29      [self unlockWrite];
    1.30 @@ -142,7 +146,7 @@
    1.31      }
    1.32  
    1.33      if ([NSError setError:error fromPEPStatus:theStatus]) {
    1.34 -        decryptMessageDictFree(_src, _dst, _keys);
    1.35 +        decryptMessageDictFree(_src, _dst, theKeys);
    1.36          return nil;
    1.37      }
    1.38  
    1.39 @@ -158,20 +162,15 @@
    1.40          dst_ = PEP_messageDictFromStruct(_src);
    1.41      }
    1.42  
    1.43 -    NSArray *keys_ = nil;
    1.44 -    if (_keys) {
    1.45 -        keys_ = PEP_arrayFromStringlist(_keys);
    1.46 -    }
    1.47 -
    1.48      if (theFlags & PEP_decrypt_flag_untrusted_server) {
    1.49          [messageDict replaceWithMessage:_src];
    1.50      }
    1.51  
    1.52 -    decryptMessageDictFree(_src, _dst, _keys);
    1.53 +    if (extraKeys) {
    1.54 +        *extraKeys = PEP_arrayFromStringlist(theKeys);
    1.55 +    }
    1.56  
    1.57 -    if (extraKeys) {
    1.58 -        *extraKeys = keys_;
    1.59 -    }
    1.60 +    decryptMessageDictFree(_src, _dst, theKeys);
    1.61  
    1.62      if (rating) {
    1.63          *rating = internalRating;