ENGINE-198: merged plaintext fix for MIME_decrypt_message into default
authorKrista Bennett <krista@pep-project.org>
Tue, 02 May 2017 09:32:38 +0200
changeset 17444d42c179c6bb
parent 1742 fe5c1dc9d028
parent 1743 67f9eecd5535
child 1745 373a181d7185
child 1746 498b0671ff4e
ENGINE-198: merged plaintext fix for MIME_decrypt_message into default
src/message_api.c
     1.1 --- a/src/message_api.c	Tue May 02 02:11:09 2017 +0200
     1.2 +++ b/src/message_api.c	Tue May 02 09:32:38 2017 +0200
     1.3 @@ -2549,6 +2549,12 @@
     1.4      PEP_decrypt_flags_t *flags
     1.5  )
     1.6  {
     1.7 +    assert(mimetext);
     1.8 +    assert(mime_plaintext);
     1.9 +    assert(keylist);
    1.10 +    assert(rating);
    1.11 +    assert(flags);
    1.12 +
    1.13      PEP_STATUS status = PEP_STATUS_OK;
    1.14      message* tmp_msg = NULL;
    1.15      message* dec_msg = NULL;
    1.16 @@ -2563,12 +2569,19 @@
    1.17                                                  keylist,
    1.18                                                  rating,
    1.19                                                  flags);
    1.20 +                                                
    1.21 +    if (!dec_msg && (decrypt_status == PEP_UNENCRYPTED || decrypt_status == PEP_VERIFIED)) {
    1.22 +        dec_msg = message_dup(tmp_msg);
    1.23 +    }
    1.24 +        
    1.25      if (decrypt_status > PEP_CANNOT_DECRYPT_UNKNOWN)
    1.26      {
    1.27          status = decrypt_status;
    1.28          goto pep_error;
    1.29      }
    1.30  
    1.31 +    assert(dec_msg);
    1.32 +    
    1.33      if (!dec_msg) {
    1.34          status = PEP_UNKNOWN_ERROR;
    1.35          goto pep_error;
    1.36 @@ -2579,6 +2592,7 @@
    1.37      if (status == PEP_STATUS_OK)
    1.38      {
    1.39          free(tmp_msg);
    1.40 +        free(dec_msg);
    1.41          return decrypt_status;
    1.42      }
    1.43