ENGINE-316: fixed bad status return when decrypted message couldn't be verified
authorKrista Bennett <krista@pep-project.org>
Wed, 22 Nov 2017 10:28:40 +0100
changeset 229567d86917978d
parent 2292 61a4c53de0d6
child 2296 1a12f577ac71
child 2300 cfa7b4d7e59d
ENGINE-316: fixed bad status return when decrypted message couldn't be verified
src/message_api.c
     1.1 --- a/src/message_api.c	Tue Nov 21 18:11:56 2017 +0100
     1.2 +++ b/src/message_api.c	Wed Nov 22 10:28:40 2017 +0100
     1.3 @@ -2130,13 +2130,21 @@
     1.4                                     stringlist_t** keylist,
     1.5                                     PEP_STATUS* decrypt_status,
     1.6                                     PEP_cryptotech crypto) {
     1.7 -                                       
     1.8 +
     1.9 +    assert(src && src->from);
    1.10 +    
    1.11 +    if (!src && !src->from)
    1.12 +        return PEP_ILLEGAL_VALUE;
    1.13 +
    1.14 +    PEP_STATUS _cached_decrypt_status = *decrypt_status;
    1.15 +        
    1.16      pEp_identity* sender = src->from;
    1.17  
    1.18      bloblist_t* detached_sig = NULL;
    1.19      PEP_STATUS status = _get_detached_signature(msg, &detached_sig);
    1.20      stringlist_t *verify_keylist = NULL;
    1.21      
    1.22 +    
    1.23      if (detached_sig) {
    1.24          char* dsig_text = detached_sig->value;
    1.25          size_t dsig_size = detached_sig->size;
    1.26 @@ -2171,10 +2179,13 @@
    1.27          *decrypt_status = decrypt_and_verify(session, ctext, csize,
    1.28                                              NULL, 0,
    1.29                                              &ptext, &psize, keylist);
    1.30 -        return PEP_STATUS_OK;
    1.31 +        
    1.32      }
    1.33  
    1.34 -    return status;
    1.35 +    if (*decrypt_status != PEP_DECRYPTED_AND_VERIFIED)
    1.36 +        *decrypt_status = _cached_decrypt_status;                                
    1.37 +
    1.38 +    return PEP_STATUS_OK;
    1.39  }
    1.40  
    1.41  static PEP_STATUS _decrypt_in_pieces(PEP_SESSION session,