src/message_api.c
branchENGINE-214
changeset 2031 b87314b30061
parent 2030 4df2470d9eb2
child 2034 b6742bbca2d2
     1.1 --- a/src/message_api.c	Mon Sep 04 10:08:10 2017 +0200
     1.2 +++ b/src/message_api.c	Tue Sep 05 13:47:36 2017 +0200
     1.3 @@ -424,6 +424,8 @@
     1.4      
     1.5      if (!envelope) {
     1.6          _envelope = extract_minimal_envelope(attachment, PEP_dir_outgoing);
     1.7 +        if (!_envelope)
     1.8 +            return PEP_UNKNOWN_ERROR;
     1.9          envelope = _envelope;
    1.10      }
    1.11      
    1.12 @@ -1376,7 +1378,15 @@
    1.13              _src = src;
    1.14          }
    1.15          else {
    1.16 -            _src = wrap_message_as_attachment(NULL, src);
    1.17 +            // encrypt inner message
    1.18 +            message* inner_message = NULL;
    1.19 +            status = encrypt_message(session, src, extra, &inner_message,
    1.20 +                                     enc_format, flags | PEP_encrypt_flag_dont_raise_headers);                         
    1.21 +            _src = wrap_message_as_attachment(NULL, inner_message);
    1.22 +            if (_src == NULL) {
    1.23 +                status = PEP_UNKNOWN_ERROR;
    1.24 +                goto pep_error;
    1.25 +            }
    1.26              msg = clone_to_empty_message(_src);
    1.27          }
    1.28          if (msg == NULL)