ENGINE-432: fixed some missed guards from empty message->from fields. Test cases next (testflight found crashes in the wild on this)
authorKrista Bennett <krista@pep-project.org>
Tue, 28 Aug 2018 13:18:56 +0200
changeset 289408a376148029
parent 2828 eb82afc171ef
child 2895 fcc598cc5e2f
ENGINE-432: fixed some missed guards from empty message->from fields. Test cases next (testflight found crashes in the wild on this)
src/message_api.c
     1.1 --- a/src/message_api.c	Tue Aug 14 15:46:57 2018 +0200
     1.2 +++ b/src/message_api.c	Tue Aug 28 13:18:56 2018 +0200
     1.3 @@ -3109,13 +3109,15 @@
     1.4      bool imported_keys = import_attached_keys(session, src, NULL);
     1.5  
     1.6      // FIXME: is this really necessary here?
     1.7 -    if (!is_me(session, src->from))
     1.8 -        status = update_identity(session, src->from);
     1.9 -    else
    1.10 -        status = myself(session, src->from);
    1.11 +    if (src->from) {
    1.12 +        if (!is_me(session, src->from))
    1.13 +            status = update_identity(session, src->from);
    1.14 +        else
    1.15 +            status = myself(session, src->from);
    1.16          
    1.17 -    if (status != PEP_STATUS_OK)
    1.18 -        return status;
    1.19 +        if (status != PEP_STATUS_OK)
    1.20 +            return status;
    1.21 +    }
    1.22      
    1.23      /*** End Import any attached public keys and update identities accordingly ***/
    1.24      
    1.25 @@ -3350,7 +3352,7 @@
    1.26          
    1.27          // Ok, so if it was signed and it's all verified, we can update
    1.28          // eligible signer comm_types to PEP_ct_pEp_*
    1.29 -        if (decrypt_status == PEP_DECRYPTED_AND_VERIFIED && is_pep_msg)
    1.30 +        if (decrypt_status == PEP_DECRYPTED_AND_VERIFIED && is_pep_msg && calculated_src->from)
    1.31              status = update_sender_to_pep_trust(session, calculated_src->from, _keylist);
    1.32  
    1.33          /* Ok, now we have a keylist used for decryption/verification.