mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +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;
|
return rfc724_mid_exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn cb_set_config(context: &Context, key: *const libc::c_char, value: *const libc::c_char) {
|
fn cb_set_config(context: &Context, key: &str, value: Option<&str>) {
|
||||||
let v = if value.is_null() {
|
context.sql.set_config(context, key, value).ok();
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(as_str(value))
|
|
||||||
};
|
|
||||||
context.sql.set_config(context, as_str(key), v).ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
|
|||||||
@@ -914,13 +914,7 @@ impl Imap {
|
|||||||
let key = format!("imap.mailbox.{}", folder.as_ref());
|
let key = format!("imap.mailbox.{}", folder.as_ref());
|
||||||
let val = format!("{}:{}", uidvalidity, lastseenuid);
|
let val = format!("{}:{}", uidvalidity, lastseenuid);
|
||||||
|
|
||||||
unsafe {
|
(self.set_config)(context, &key, Some(&val));
|
||||||
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 _);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_single_msg<S: AsRef<str>>(
|
fn fetch_single_msg<S: AsRef<str>>(
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ the online state. */
|
|||||||
|
|
||||||
pub type dc_precheck_imf_t =
|
pub type dc_precheck_imf_t =
|
||||||
unsafe fn(_: &Context, _: *const libc::c_char, _: &str, _: u32) -> libc::c_int;
|
unsafe fn(_: &Context, _: *const libc::c_char, _: &str, _: u32) -> libc::c_int;
|
||||||
pub type dc_set_config_t =
|
pub type dc_set_config_t = fn(_: &Context, _: &str, _: Option<&str>) -> ();
|
||||||
unsafe fn(_: &Context, _: *const libc::c_char, _: *const libc::c_char) -> ();
|
|
||||||
pub type dc_get_config_t = fn(_: &Context, _: &str) -> Option<String>;
|
pub type dc_get_config_t = fn(_: &Context, _: &str) -> Option<String>;
|
||||||
|
|
||||||
pub type sqlite_int64 = i64;
|
pub type sqlite_int64 = i64;
|
||||||
|
|||||||
Reference in New Issue
Block a user