Browse Source

encrypt_message: do not disallow Bcc even when To and/or Cc are also present; factor

Instead of bragging about code duplication in comments, factor.

Apart from the change in Bcc handling, this keeps the current semantics...  (See
next commit)
ENGINE-967
Luca Saiu 9 months ago
parent
commit
7425e6b0bd
1 changed files with 30 additions and 85 deletions
  1. +30
    -85
      src/message_api.c

+ 30
- 85
src/message_api.c View File

@ -2749,93 +2749,38 @@ DYNAMIC_API PEP_STATUS encrypt_message(
// Update the identities and gather key and version information
// for sending
//
if (enc_format != PEP_enc_none && (_il = src->bcc) && _il->ident)
// BCC limited support:
# define UPDATE_STATE_FOR_IDENT_LIST_AND_JUMP_ON_ERROR(ident_list_actual) \
do { \
identity_list *ident_list = (ident_list_actual); \
if (ident_list) { \
_status = _update_state_for_ident_list( \
session, src->from, ident_list, \
&_k, \
&max_comm_type, \
&max_version_major, \
&max_version_minor, \
&has_pEp_user, \
&dest_keys_found, \
false \
); \
switch (_status) { \
case PEP_PASSPHRASE_REQUIRED: \
case PEP_PASSPHRASE_FOR_NEW_KEYS_REQUIRED: \
case PEP_WRONG_PASSPHRASE: \
goto pEp_error; \
case PEP_STATUS_OK: \
break; \
default: \
status = PEP_UNENCRYPTED; \
goto pEp_error; \
} \
} \
} while (false)
{
// - App splits mails with BCC in multiple mails.
// - Each email is encrypted separately
if(_il->next || (src->to && src->to->ident) || (src->cc && src->cc->ident))
{
// Only one Bcc with no other recipient allowed for now
return PEP_ILLEGAL_VALUE;
}
// If you think this call is a beast, try the cut-and-pasted code 3 x
PEP_STATUS _status = _update_state_for_ident_list(
session, src->from, _il,
&_k,
&max_comm_type,
&max_version_major,
&max_version_minor,
&has_pEp_user,
&dest_keys_found,
true);
switch (_status) {
case PEP_PASSPHRASE_REQUIRED:
case PEP_PASSPHRASE_FOR_NEW_KEYS_REQUIRED:
case PEP_WRONG_PASSPHRASE:
status = _status;
goto pEp_error;
case PEP_STATUS_OK:
break;
default:
status = PEP_UNENCRYPTED;
goto pEp_error;
}
}
else // Non BCC
{
// If you think this call is a beast, try the cut-and-pasted code 3 x
PEP_STATUS _status = PEP_STATUS_OK;
if (src->to) {
_status = _update_state_for_ident_list(
session, src->from, src->to,
&_k,
&max_comm_type,
&max_version_major,
&max_version_minor,
&has_pEp_user,
&dest_keys_found,
false
);
switch (_status) {
case PEP_PASSPHRASE_REQUIRED:
case PEP_PASSPHRASE_FOR_NEW_KEYS_REQUIRED:
case PEP_WRONG_PASSPHRASE:
goto pEp_error;
case PEP_STATUS_OK:
break;
default:
status = PEP_UNENCRYPTED;
goto pEp_error;
}
}
if (src->cc) {
_status = _update_state_for_ident_list(
session, src->from, src->cc,
&_k,
&max_comm_type,
&max_version_major,
&max_version_minor,
&has_pEp_user,
&dest_keys_found,
false
);
switch (_status) {
case PEP_PASSPHRASE_REQUIRED:
case PEP_PASSPHRASE_FOR_NEW_KEYS_REQUIRED:
case PEP_WRONG_PASSPHRASE:
goto pEp_error;
case PEP_STATUS_OK:
break;
default:
status = PEP_UNENCRYPTED;
goto pEp_error;
}
}
UPDATE_STATE_FOR_IDENT_LIST_AND_JUMP_ON_ERROR (src->to);
UPDATE_STATE_FOR_IDENT_LIST_AND_JUMP_ON_ERROR (src->cc);
UPDATE_STATE_FOR_IDENT_LIST_AND_JUMP_ON_ERROR (src->bcc);
}
if (max_version_major < 2)


Loading…
Cancel
Save