This commit is contained in:
holger krekel
2019-09-30 01:25:19 +02:00
parent cbfb391714
commit a6bd68e16e

View File

@@ -37,6 +37,8 @@ use crate::wrapmime::*;
static mut VERSION_CONTENT: [libc::c_char; 13] = static mut VERSION_CONTENT: [libc::c_char; 13] =
[86, 101, 114, 115, 105, 111, 110, 58, 32, 49, 13, 10, 0]; [86, 101, 114, 115, 105, 111, 110, 58, 32, 49, 13, 10, 0];
type Fingerprint = String;
#[derive(Debug)] #[derive(Debug)]
pub struct EncryptHelper { pub struct EncryptHelper {
pub prefer_encrypt: EncryptPreference, pub prefer_encrypt: EncryptPreference,
@@ -300,7 +302,6 @@ pub fn try_decrypt(
/* possibly perform decryption */ /* possibly perform decryption */
let mut private_keyring = Keyring::default(); let mut private_keyring = Keyring::default();
let mut public_keyring_for_validate = Keyring::default(); let mut public_keyring_for_validate = Keyring::default();
let mut encrypted = false;
let mut signatures = HashSet::default(); let mut signatures = HashSet::default();
let mut gossipped_addr = HashSet::default(); let mut gossipped_addr = HashSet::default();
@@ -324,7 +325,7 @@ pub fn try_decrypt(
} }
let mut gossip_headers = ptr::null_mut(); let mut gossip_headers = ptr::null_mut();
encrypted = decrypt_if_autocrypt_message( let gossip_headers = decrypt_if_autocrypt_message(
context, context,
in_out_message, in_out_message,
&private_keyring, &private_keyring,
@@ -335,7 +336,6 @@ pub fn try_decrypt(
if !gossip_headers.is_null() { if !gossip_headers.is_null() {
gossipped_addr = gossipped_addr =
update_gossip_peerstates(context, message_time, imffields, gossip_headers)?; update_gossip_peerstates(context, message_time, imffields, gossip_headers)?;
unsafe { mailimf_fields_free(gossip_headers) };
} }
} }
} }
@@ -483,7 +483,7 @@ fn decrypt_if_autocrypt_message(
public_keyring_for_validate: &Keyring, public_keyring_for_validate: &Keyring,
ret_valid_signatures: &mut HashSet<String>, ret_valid_signatures: &mut HashSet<String>,
ret_gossip_headers: *mut *mut mailimf_fields, ret_gossip_headers: *mut *mut mailimf_fields,
) -> Result<(bool)> { ) -> Result<(Vec<String>, HashSet<String>)> {
/* The returned bool is true if we detected an Autocrypt-encrypted /* The returned bool is true if we detected an Autocrypt-encrypted
message and successfully decrypted it. Decryption then modifies the message and successfully decrypted it. Decryption then modifies the
passed in mime structure in place. The returned bool is false passed in mime structure in place. The returned bool is false
@@ -501,12 +501,11 @@ fn decrypt_if_autocrypt_message(
Ok(res) => res, Ok(res) => res,
}; };
let decrypted_mime = decrypt_part( let (decrypted_mime, signatures, gossip_headers) = decrypt_part(
context, context,
encrypted_data_part, encrypted_data_part,
private_keyring, private_keyring,
public_keyring_for_validate, public_keyring_for_validate,
ret_valid_signatures,
)?; )?;
// decrypted_mime is a dangling pointer which we now put into mailmime's Ownership // decrypted_mime is a dangling pointer which we now put into mailmime's Ownership
unsafe { unsafe {
@@ -533,6 +532,7 @@ fn decrypt_if_autocrypt_message(
} }
} }
} }
unsafe { mailimf_fields_free(gossip_headers) };
Ok(true) Ok(true)
} }