mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 13:56:30 +03:00
audit use of to_cstring and fix ub
This commit is contained in:
committed by
holger krekel
parent
618087e5a7
commit
c68e7ae14e
@@ -161,24 +161,20 @@ pub unsafe fn dc_mimefactory_load_msg(
|
||||
for row in rows {
|
||||
let (authname, addr) = row?;
|
||||
let addr_c = to_cstring(addr);
|
||||
if clist_search_string_nocase(
|
||||
(*factory).recipients_addr,
|
||||
addr_c.as_ptr(),
|
||||
) == 0
|
||||
{
|
||||
if clist_search_string_nocase((*factory).recipients_addr, addr_c) == 0 {
|
||||
clist_insert_after(
|
||||
(*factory).recipients_names,
|
||||
(*(*factory).recipients_names).last,
|
||||
if !authname.is_empty() {
|
||||
dc_strdup(to_cstring(authname).as_ptr())
|
||||
to_cstring(authname)
|
||||
} else {
|
||||
0 as *mut libc::c_char
|
||||
std::ptr::null_mut()
|
||||
} as *mut libc::c_void,
|
||||
);
|
||||
clist_insert_after(
|
||||
(*factory).recipients_addr,
|
||||
(*(*factory).recipients_addr).last,
|
||||
dc_strdup(addr_c.as_ptr()) as *mut libc::c_void,
|
||||
addr_c as *mut libc::c_void,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -241,8 +237,8 @@ pub unsafe fn dc_mimefactory_load_msg(
|
||||
);
|
||||
match row {
|
||||
Ok((in_reply_to, references)) => {
|
||||
(*factory).in_reply_to = dc_strdup(to_cstring(in_reply_to).as_ptr());
|
||||
(*factory).references = dc_strdup(to_cstring(references).as_ptr());
|
||||
(*factory).in_reply_to = to_cstring(in_reply_to);
|
||||
(*factory).references = to_cstring(references);
|
||||
}
|
||||
Err(err) => {
|
||||
error!(
|
||||
@@ -266,32 +262,24 @@ pub unsafe fn dc_mimefactory_load_msg(
|
||||
|
||||
unsafe fn load_from(mut factory: *mut dc_mimefactory_t) {
|
||||
let context = (*factory).context;
|
||||
(*factory).from_addr = strdup(
|
||||
to_cstring(
|
||||
context
|
||||
.sql
|
||||
.get_config(context, "configured_addr")
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
.as_ptr(),
|
||||
(*factory).from_addr = to_cstring(
|
||||
context
|
||||
.sql
|
||||
.get_config(context, "configured_addr")
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
(*factory).from_displayname = strdup(
|
||||
to_cstring(
|
||||
context
|
||||
.sql
|
||||
.get_config(context, "displayname")
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
.as_ptr(),
|
||||
|
||||
(*factory).from_displayname = to_cstring(
|
||||
context
|
||||
.sql
|
||||
.get_config(context, "displayname")
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
(*factory).selfstatus = strdup(
|
||||
to_cstring(
|
||||
context
|
||||
.sql
|
||||
.get_config(context, "selfstatus")
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
.as_ptr(),
|
||||
(*factory).selfstatus = to_cstring(
|
||||
context
|
||||
.sql
|
||||
.get_config(context, "selfstatus")
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
if (*factory).selfstatus.is_null() {
|
||||
(*factory).selfstatus = dc_stock_str((*factory).context, 13)
|
||||
@@ -1178,7 +1166,7 @@ unsafe fn build_body_file(
|
||||
let res = ts
|
||||
.format(&format!("voice-message_%Y-%m-%d_%H-%M-%S.{}", suffix))
|
||||
.to_string();
|
||||
filename_to_send = strdup(to_cstring(res).as_ptr());
|
||||
filename_to_send = to_cstring(res);
|
||||
} else if (*msg).type_0 == 40 {
|
||||
filename_to_send = dc_get_filename(pathNfilename)
|
||||
} else if (*msg).type_0 == 20 || (*msg).type_0 == 21 {
|
||||
|
||||
Reference in New Issue
Block a user