mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
Make cb_set_config() safe
This commit is contained in:
@@ -233,13 +233,8 @@ unsafe fn cb_precheck_imf(
|
||||
return rfc724_mid_exists;
|
||||
}
|
||||
|
||||
unsafe fn cb_set_config(context: &Context, key: *const libc::c_char, value: *const libc::c_char) {
|
||||
let v = if value.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(as_str(value))
|
||||
};
|
||||
context.sql.set_config(context, as_str(key), v).ok();
|
||||
fn cb_set_config(context: &Context, key: &str, value: Option<&str>) {
|
||||
context.sql.set_config(context, key, value).ok();
|
||||
}
|
||||
|
||||
/* *
|
||||
|
||||
@@ -914,13 +914,7 @@ impl Imap {
|
||||
let key = format!("imap.mailbox.{}", folder.as_ref());
|
||||
let val = format!("{}:{}", uidvalidity, lastseenuid);
|
||||
|
||||
unsafe {
|
||||
let key_c = to_cstring(key);
|
||||
let val_c = to_cstring(val);
|
||||
(self.set_config)(context, key_c, val_c);
|
||||
free(key_c as *mut _);
|
||||
free(val_c as *mut _);
|
||||
};
|
||||
(self.set_config)(context, &key, Some(&val));
|
||||
}
|
||||
|
||||
fn fetch_single_msg<S: AsRef<str>>(
|
||||
|
||||
@@ -34,8 +34,7 @@ the online state. */
|
||||
|
||||
pub type dc_precheck_imf_t =
|
||||
unsafe fn(_: &Context, _: *const libc::c_char, _: &str, _: u32) -> libc::c_int;
|
||||
pub type dc_set_config_t =
|
||||
unsafe fn(_: &Context, _: *const libc::c_char, _: *const libc::c_char) -> ();
|
||||
pub type dc_set_config_t = fn(_: &Context, _: &str, _: Option<&str>) -> ();
|
||||
pub type dc_get_config_t = fn(_: &Context, _: &str) -> Option<String>;
|
||||
|
||||
pub type sqlite_int64 = i64;
|
||||
|
||||
Reference in New Issue
Block a user