ENGINE-291: putting in an empty string fixes this issue. We now test when wrapping messages for this.
authorKrista Bennett <krista@pep-project.org>
Mon, 23 Oct 2017 12:50:53 +0200
changeset 218822d08577d0f3
parent 2186 079fb1bdf0af
child 2189 598eb3551521
child 2190 c98dd5d06c84
ENGINE-291: putting in an empty string fixes this issue. We now test when wrapping messages for this.
src/message_api.c
     1.1 --- a/src/message_api.c	Mon Oct 23 11:24:21 2017 +0200
     1.2 +++ b/src/message_api.c	Mon Oct 23 12:50:53 2017 +0200
     1.3 @@ -770,7 +770,7 @@
     1.4      PEP_STATUS status = PEP_STATUS_OK;
     1.5  
     1.6      replace_opt_field(attachment, "X-pEp-Version", PEP_VERSION);
     1.7 -
     1.8 +        
     1.9      if (!_envelope) {
    1.10          _envelope = extract_minimal_envelope(attachment, PEP_dir_outgoing);
    1.11          status = generate_message_id(_envelope);
    1.12 @@ -787,13 +787,20 @@
    1.13          _envelope->longmsg = encapsulate_message_wrap_info("TRANSPORT", _envelope->longmsg);
    1.14      }
    1.15      char* message_text = NULL;
    1.16 +    
    1.17 +    if (!attachment->shortmsg) {
    1.18 +        attachment->shortmsg = strdup("");
    1.19 +        if (!attachment->shortmsg)
    1.20 +            goto enomem;
    1.21 +    }
    1.22 +    
    1.23 +    /* prevent introduction of pEp in inner message */
    1.24 +        
    1.25      /* Turn message into a MIME-blob */
    1.26      status = mime_encode_message(attachment, false, &message_text);
    1.27 -    
    1.28 -    if (status != PEP_STATUS_OK) {
    1.29 -        free(_envelope);
    1.30 -        return NULL;
    1.31 -    }
    1.32 +        
    1.33 +    if (status != PEP_STATUS_OK)
    1.34 +        goto enomem;
    1.35      
    1.36      size_t message_len = strlen(message_text);
    1.37      
    1.38 @@ -804,6 +811,12 @@
    1.39      if (keep_orig_subject && attachment->shortmsg)
    1.40          _envelope->shortmsg = strdup(attachment->shortmsg);
    1.41      return _envelope;
    1.42 +    
    1.43 +enomem:
    1.44 +    if (!envelope) {
    1.45 +        free(_envelope);
    1.46 +        return NULL;
    1.47 +    }
    1.48  }
    1.49  
    1.50  static PEP_STATUS encrypt_PGP_MIME(