ENGINE-287: encrypt_message_for_self() should now wrap the message appropriately. I hope. :)
1.1 --- a/src/message_api.c Mon Oct 23 10:37:30 2017 +0200
1.2 +++ b/src/message_api.c Mon Oct 23 11:23:28 2017 +0200
1.3 @@ -1513,8 +1513,6 @@
1.4 return ADD_TO_LOG(status);
1.5 }
1.6
1.7 -
1.8 -// FIXME: Update if needed for the wrapped fun bits
1.9 DYNAMIC_API PEP_STATUS encrypt_message_for_self(
1.10 PEP_SESSION session,
1.11 pEp_identity* target_id,
1.12 @@ -1527,6 +1525,7 @@
1.13 PEP_STATUS status = PEP_STATUS_OK;
1.14 message * msg = NULL;
1.15 stringlist_t * keys = NULL;
1.16 + message* _src = src;
1.17
1.18 assert(session);
1.19 assert(src);
1.20 @@ -1566,24 +1565,20 @@
1.21 if (!(flags & PEP_encrypt_flag_force_no_attached_key))
1.22 _attach_key(session, target_fpr, src);
1.23
1.24 - msg = clone_to_empty_message(src);
1.25 + _src = wrap_message_as_attachment(NULL, src, session->unencrypted_subject);
1.26 + if (!_src)
1.27 + goto pep_error;
1.28 +
1.29 + msg = clone_to_empty_message(_src);
1.30 if (msg == NULL)
1.31 goto enomem;
1.32
1.33 switch (enc_format) {
1.34 case PEP_enc_PGP_MIME:
1.35 case PEP_enc_PEP: // BUG: should be implemented extra
1.36 - status = encrypt_PGP_MIME(session, src, keys, msg, flags);
1.37 + status = encrypt_PGP_MIME(session, _src, keys, msg, flags);
1.38 break;
1.39
1.40 - // case PEP_enc_pieces:
1.41 - // status = encrypt_PGP_in_pieces(session, src, keys, msg, flags);
1.42 - // break;
1.43 -
1.44 - /* case PEP_enc_PEP:
1.45 - NOT_IMPLEMENTED */
1.46 - // TODO: implement
1.47 -
1.48 default:
1.49 assert(0);
1.50 status = PEP_ILLEGAL_VALUE;
1.51 @@ -1604,8 +1599,8 @@
1.52 }
1.53
1.54 if (msg) {
1.55 - if (src->id) {
1.56 - msg->id = strdup(src->id);
1.57 + if (_src->id) {
1.58 + msg->id = strdup(_src->id);
1.59 assert(msg->id);
1.60 if (msg->id == NULL)
1.61 goto enomem;
1.62 @@ -1613,6 +1608,10 @@
1.63 }
1.64
1.65 *dst = msg;
1.66 +
1.67 + if (src != _src)
1.68 + free_message(_src);
1.69 +
1.70 return status;
1.71
1.72 enomem:
1.73 @@ -1621,6 +1620,8 @@
1.74 pep_error:
1.75 free_stringlist(keys);
1.76 free_message(msg);
1.77 + if (src != _src)
1.78 + free_message(_src);
1.79
1.80 return ADD_TO_LOG(status);
1.81 }