mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
Merge pull request #296 from deltachat/remove_gotos_dc_e2ee
Remove gotos from dc_e2ee
This commit is contained in:
179
src/dc_e2ee.rs
179
src/dc_e2ee.rs
@@ -66,7 +66,7 @@ pub unsafe fn dc_e2ee_encrypt(
|
|||||||
mut in_out_message: *mut mailmime,
|
mut in_out_message: *mut mailmime,
|
||||||
helper: &mut dc_e2ee_helper_t,
|
helper: &mut dc_e2ee_helper_t,
|
||||||
) {
|
) {
|
||||||
let mut current_block: u64 = 0;
|
let mut ok_to_continue = true;
|
||||||
let mut col: libc::c_int = 0i32;
|
let mut col: libc::c_int = 0i32;
|
||||||
let mut do_encrypt: libc::c_int = 0i32;
|
let mut do_encrypt: libc::c_int = 0i32;
|
||||||
/*just a pointer into mailmime structure, must not be freed*/
|
/*just a pointer into mailmime structure, must not be freed*/
|
||||||
@@ -283,7 +283,7 @@ pub unsafe fn dc_e2ee_encrypt(
|
|||||||
);
|
);
|
||||||
mailmime_write_mem(plain, &mut col, message_to_encrypt);
|
mailmime_write_mem(plain, &mut col, message_to_encrypt);
|
||||||
if (*plain).str_0.is_null() || (*plain).len <= 0 {
|
if (*plain).str_0.is_null() || (*plain).len <= 0 {
|
||||||
current_block = 14181132614457621749;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
if let Some(ctext_v) = dc_pgp_pk_encrypt(
|
if let Some(ctext_v) = dc_pgp_pk_encrypt(
|
||||||
(*plain).str_0 as *const libc::c_void,
|
(*plain).str_0 as *const libc::c_void,
|
||||||
@@ -340,24 +340,18 @@ pub unsafe fn dc_e2ee_encrypt(
|
|||||||
(*encrypted_part).mm_parent = in_out_message;
|
(*encrypted_part).mm_parent = in_out_message;
|
||||||
mailmime_free(message_to_encrypt);
|
mailmime_free(message_to_encrypt);
|
||||||
(*helper).encryption_successfull = 1i32;
|
(*helper).encryption_successfull = 1i32;
|
||||||
current_block = 13824533195664196414;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
current_block = 13824533195664196414;
|
|
||||||
}
|
}
|
||||||
match current_block {
|
if ok_to_continue {
|
||||||
14181132614457621749 => {}
|
let aheader = Aheader::new(addr, public_key, prefer_encrypt);
|
||||||
_ => {
|
mailimf_fields_add(
|
||||||
let aheader = Aheader::new(addr, public_key, prefer_encrypt);
|
imffields_unprotected,
|
||||||
mailimf_fields_add(
|
mailimf_field_new_custom(
|
||||||
imffields_unprotected,
|
"Autocrypt".strdup(),
|
||||||
mailimf_field_new_custom(
|
aheader.to_string().strdup(),
|
||||||
"Autocrypt".strdup(),
|
),
|
||||||
aheader.to_string().strdup(),
|
);
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -378,7 +372,7 @@ unsafe fn new_data_part(
|
|||||||
default_content_type: *mut libc::c_char,
|
default_content_type: *mut libc::c_char,
|
||||||
default_encoding: libc::c_int,
|
default_encoding: libc::c_int,
|
||||||
) -> *mut mailmime {
|
) -> *mut mailmime {
|
||||||
let mut current_block: u64;
|
let mut ok_to_continue = true;
|
||||||
//char basename_buf[PATH_MAX];
|
//char basename_buf[PATH_MAX];
|
||||||
let mut encoding: *mut mailmime_mechanism;
|
let mut encoding: *mut mailmime_mechanism;
|
||||||
let content: *mut mailmime_content;
|
let content: *mut mailmime_content;
|
||||||
@@ -398,7 +392,7 @@ unsafe fn new_data_part(
|
|||||||
}
|
}
|
||||||
content = mailmime_content_new_with_str(content_type_str);
|
content = mailmime_content_new_with_str(content_type_str);
|
||||||
if content.is_null() {
|
if content.is_null() {
|
||||||
current_block = 16266721588079097885;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
do_encoding = 1i32;
|
do_encoding = 1i32;
|
||||||
if (*(*content).ct_type).tp_type == MAILMIME_TYPE_COMPOSITE_TYPE as libc::c_int {
|
if (*(*content).ct_type).tp_type == MAILMIME_TYPE_COMPOSITE_TYPE as libc::c_int {
|
||||||
@@ -426,54 +420,44 @@ unsafe fn new_data_part(
|
|||||||
}
|
}
|
||||||
encoding = mailmime_mechanism_new(encoding_type, 0 as *mut libc::c_char);
|
encoding = mailmime_mechanism_new(encoding_type, 0 as *mut libc::c_char);
|
||||||
if encoding.is_null() {
|
if encoding.is_null() {
|
||||||
current_block = 16266721588079097885;
|
ok_to_continue = false;
|
||||||
} else {
|
|
||||||
current_block = 11057878835866523405;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
current_block = 11057878835866523405;
|
|
||||||
}
|
}
|
||||||
match current_block {
|
if ok_to_continue {
|
||||||
16266721588079097885 => {}
|
mime_fields = mailmime_fields_new_with_data(
|
||||||
_ => {
|
encoding,
|
||||||
mime_fields = mailmime_fields_new_with_data(
|
0 as *mut libc::c_char,
|
||||||
encoding,
|
0 as *mut libc::c_char,
|
||||||
0 as *mut libc::c_char,
|
0 as *mut mailmime_disposition,
|
||||||
0 as *mut libc::c_char,
|
0 as *mut mailmime_language,
|
||||||
0 as *mut mailmime_disposition,
|
);
|
||||||
0 as *mut mailmime_language,
|
if mime_fields.is_null() {
|
||||||
);
|
ok_to_continue = false;
|
||||||
if mime_fields.is_null() {
|
} else {
|
||||||
current_block = 16266721588079097885;
|
mime = mailmime_new_empty(content, mime_fields);
|
||||||
|
if mime.is_null() {
|
||||||
|
mailmime_fields_free(mime_fields);
|
||||||
|
mailmime_content_free(content);
|
||||||
} else {
|
} else {
|
||||||
mime = mailmime_new_empty(content, mime_fields);
|
if !data.is_null()
|
||||||
if mime.is_null() {
|
&& data_bytes > 0
|
||||||
mailmime_fields_free(mime_fields);
|
&& (*mime).mm_type == MAILMIME_SINGLE as libc::c_int
|
||||||
mailmime_content_free(content);
|
{
|
||||||
} else {
|
mailmime_set_body_text(mime, data as *mut libc::c_char, data_bytes);
|
||||||
if !data.is_null()
|
|
||||||
&& data_bytes > 0
|
|
||||||
&& (*mime).mm_type == MAILMIME_SINGLE as libc::c_int
|
|
||||||
{
|
|
||||||
mailmime_set_body_text(mime, data as *mut libc::c_char, data_bytes);
|
|
||||||
}
|
|
||||||
return mime;
|
|
||||||
}
|
}
|
||||||
current_block = 13668317689588454213;
|
return mime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match current_block {
|
|
||||||
16266721588079097885 => {
|
if ok_to_continue == false {
|
||||||
if !encoding.is_null() {
|
if !encoding.is_null() {
|
||||||
mailmime_mechanism_free(encoding);
|
mailmime_mechanism_free(encoding);
|
||||||
}
|
}
|
||||||
if !content.is_null() {
|
if !content.is_null() {
|
||||||
mailmime_content_free(content);
|
mailmime_content_free(content);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
return 0 as *mut mailmime;
|
return 0 as *mut mailmime;
|
||||||
}
|
}
|
||||||
@@ -835,7 +819,7 @@ unsafe fn decrypt_part(
|
|||||||
ret_valid_signatures: &mut HashSet<String>,
|
ret_valid_signatures: &mut HashSet<String>,
|
||||||
ret_decrypted_mime: *mut *mut mailmime,
|
ret_decrypted_mime: *mut *mut mailmime,
|
||||||
) -> libc::c_int {
|
) -> libc::c_int {
|
||||||
let current_block: u64;
|
let mut ok_to_continue = true;
|
||||||
let mime_data: *mut mailmime_data;
|
let mime_data: *mut mailmime_data;
|
||||||
let mut mime_transfer_encoding: libc::c_int = MAILMIME_MECHANISM_BINARY as libc::c_int;
|
let mut mime_transfer_encoding: libc::c_int = MAILMIME_MECHANISM_BINARY as libc::c_int;
|
||||||
/* mmap_string_unref()'d if set */
|
/* mmap_string_unref()'d if set */
|
||||||
@@ -883,9 +867,7 @@ unsafe fn decrypt_part(
|
|||||||
decoded_data_bytes = (*mime_data).dt_data.dt_text.dt_length;
|
decoded_data_bytes = (*mime_data).dt_data.dt_text.dt_length;
|
||||||
if decoded_data.is_null() || decoded_data_bytes <= 0 {
|
if decoded_data.is_null() || decoded_data_bytes <= 0 {
|
||||||
/* no error - but no data */
|
/* no error - but no data */
|
||||||
current_block = 2554982661806928548;
|
ok_to_continue = false;
|
||||||
} else {
|
|
||||||
current_block = 4488286894823169796;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let r: libc::c_int;
|
let r: libc::c_int;
|
||||||
@@ -902,52 +884,47 @@ unsafe fn decrypt_part(
|
|||||||
|| transfer_decoding_buffer.is_null()
|
|| transfer_decoding_buffer.is_null()
|
||||||
|| decoded_data_bytes <= 0
|
|| decoded_data_bytes <= 0
|
||||||
{
|
{
|
||||||
current_block = 2554982661806928548;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
decoded_data = transfer_decoding_buffer;
|
decoded_data = transfer_decoding_buffer;
|
||||||
current_block = 4488286894823169796;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match current_block {
|
if ok_to_continue {
|
||||||
2554982661806928548 => {}
|
/* encrypted, decoded data in decoded_data now ... */
|
||||||
_ => {
|
if !(0 == has_decrypted_pgp_armor(decoded_data, decoded_data_bytes as libc::c_int)) {
|
||||||
/* encrypted, decoded data in decoded_data now ... */
|
let add_signatures = if ret_valid_signatures.is_empty() {
|
||||||
if !(0 == has_decrypted_pgp_armor(decoded_data, decoded_data_bytes as libc::c_int))
|
Some(ret_valid_signatures)
|
||||||
{
|
} else {
|
||||||
let add_signatures = if ret_valid_signatures.is_empty() {
|
None
|
||||||
Some(ret_valid_signatures)
|
};
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
/*if we already have fingerprints, do not add more; this ensures, only the fingerprints from the outer-most part are collected */
|
/*if we already have fingerprints, do not add more; this ensures, only the fingerprints from the outer-most part are collected */
|
||||||
if let Some(plain) = dc_pgp_pk_decrypt(
|
if let Some(plain) = dc_pgp_pk_decrypt(
|
||||||
decoded_data as *const libc::c_void,
|
decoded_data as *const libc::c_void,
|
||||||
decoded_data_bytes,
|
decoded_data_bytes,
|
||||||
&private_keyring,
|
&private_keyring,
|
||||||
&public_keyring_for_validate,
|
&public_keyring_for_validate,
|
||||||
add_signatures,
|
add_signatures,
|
||||||
) {
|
) {
|
||||||
let plain_bytes = plain.len();
|
let plain_bytes = plain.len();
|
||||||
let plain_buf = plain.as_ptr() as *const libc::c_char;
|
let plain_buf = plain.as_ptr() as *const libc::c_char;
|
||||||
|
|
||||||
let mut index: size_t = 0i32 as size_t;
|
let mut index: size_t = 0i32 as size_t;
|
||||||
let mut decrypted_mime: *mut mailmime = 0 as *mut mailmime;
|
let mut decrypted_mime: *mut mailmime = 0 as *mut mailmime;
|
||||||
if mailmime_parse(
|
if mailmime_parse(
|
||||||
plain_buf as *const _,
|
plain_buf as *const _,
|
||||||
plain_bytes,
|
plain_bytes,
|
||||||
&mut index,
|
&mut index,
|
||||||
&mut decrypted_mime,
|
&mut decrypted_mime,
|
||||||
) != MAIL_NO_ERROR as libc::c_int
|
) != MAIL_NO_ERROR as libc::c_int
|
||||||
|| decrypted_mime.is_null()
|
|| decrypted_mime.is_null()
|
||||||
{
|
{
|
||||||
if !decrypted_mime.is_null() {
|
if !decrypted_mime.is_null() {
|
||||||
mailmime_free(decrypted_mime);
|
mailmime_free(decrypted_mime);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
*ret_decrypted_mime = decrypted_mime;
|
|
||||||
sth_decrypted = 1i32
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
*ret_decrypted_mime = decrypted_mime;
|
||||||
|
sth_decrypted = 1i32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user