Fix for ENGINE-656
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 18 Nov 2019 15:32:27 +0100
changeset 4204e278385af49d
parent 3473 9cd6a0ad3c74
child 4205 f75e9274551f
Fix for ENGINE-656
src/message_api.c
     1.1 --- a/src/message_api.c	Tue Apr 09 09:26:27 2019 +0200
     1.2 +++ b/src/message_api.c	Mon Nov 18 15:32:27 2019 +0100
     1.3 @@ -4354,7 +4354,7 @@
     1.4  
     1.5      status = mime_decode_message(mimetext, size, &tmp_msg);
     1.6      if (status != PEP_STATUS_OK)
     1.7 -        goto pep_error;
     1.8 +        goto pEp_error;
     1.9  
    1.10      // MIME decode message delivers only addresses. We need more.
    1.11      if (tmp_msg->from) {
    1.12 @@ -4371,7 +4371,7 @@
    1.13              
    1.14          status = myself(session, tmp_msg->from);
    1.15          if (status != PEP_STATUS_OK)
    1.16 -            goto pep_error;
    1.17 +            goto pEp_error;
    1.18      }
    1.19      
    1.20      // Own identities can be retrieved here where they would otherwise
    1.21 @@ -4379,15 +4379,15 @@
    1.22      // desired. FIXME: IS it?
    1.23      status = update_identity_recip_list(session, tmp_msg->to);
    1.24      if (status != PEP_STATUS_OK)
    1.25 -        goto pep_error;
    1.26 +        goto pEp_error;
    1.27      
    1.28      status = update_identity_recip_list(session, tmp_msg->cc);
    1.29      if (status != PEP_STATUS_OK)
    1.30 -        goto pep_error;
    1.31 +        goto pEp_error;
    1.32      
    1.33      status = update_identity_recip_list(session, tmp_msg->bcc);
    1.34      if (status != PEP_STATUS_OK)
    1.35 -        goto pep_error;
    1.36 +        goto pEp_error;
    1.37      
    1.38      // This isn't incoming, though... so we need to reverse the direction
    1.39      tmp_msg->dir = PEP_dir_outgoing;
    1.40 @@ -4398,18 +4398,25 @@
    1.41                               enc_format,
    1.42                               flags);
    1.43                               
    1.44 -    if (status != PEP_STATUS_OK)
    1.45 -        goto pep_error;
    1.46 -
    1.47 -
    1.48 -    if (!enc_msg) {
    1.49 +    message* ret_msg = NULL;                         
    1.50 +    if (status == PEP_STATUS_OK || status == PEP_UNENCRYPTED)
    1.51 +        ret_msg = (status == PEP_STATUS_OK ? enc_msg : tmp_msg);
    1.52 +    else                                
    1.53 +        goto pEp_error;
    1.54 +
    1.55 +    if (status == PEP_STATUS_OK && !enc_msg) {
    1.56          status = PEP_UNKNOWN_ERROR;
    1.57 -        goto pep_error;
    1.58 +        goto pEp_error;
    1.59      }
    1.60 -
    1.61 -    status = _mime_encode_message_internal(enc_msg, false, mime_ciphertext, false);
    1.62 -
    1.63 -pep_error:
    1.64 +    
    1.65 +    PEP_STATUS tmp_status = _mime_encode_message_internal(
    1.66 +                                    ret_msg, 
    1.67 +                                    false, 
    1.68 +                                    mime_ciphertext, 
    1.69 +                                    false, 
    1.70 +                                    false);
    1.71 +
    1.72 +pEp_error:
    1.73      free_message(tmp_msg);
    1.74      free_message(enc_msg);
    1.75