mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 11:26:29 +03:00
Make dc_create_setup_code() safe (#239)
Make dc_create_setup_code() safe
This commit is contained in:
@@ -105,7 +105,7 @@ pub unsafe fn dc_initiate_key_transfer(context: &Context) -> *mut libc::c_char {
|
||||
if 0 == dc_alloc_ongoing(context) {
|
||||
return 0 as *mut libc::c_char;
|
||||
}
|
||||
setup_code = dc_create_setup_code(context);
|
||||
setup_code = to_cstring(dc_create_setup_code(context));
|
||||
if !setup_code.is_null() {
|
||||
/* this may require a keypair to be created. this may take a second ... */
|
||||
if !context
|
||||
@@ -282,7 +282,7 @@ pub unsafe extern "C" fn dc_render_setup_file(
|
||||
ret_setupfilecontent
|
||||
}
|
||||
|
||||
pub unsafe fn dc_create_setup_code(_context: &Context) -> *mut libc::c_char {
|
||||
pub fn dc_create_setup_code(_context: &Context) -> String {
|
||||
let mut random_val: uint16_t;
|
||||
let mut rng = thread_rng();
|
||||
let mut ret = String::new();
|
||||
@@ -302,7 +302,7 @@ pub unsafe fn dc_create_setup_code(_context: &Context) -> *mut libc::c_char {
|
||||
);
|
||||
}
|
||||
|
||||
to_cstring(ret)
|
||||
ret
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
|
||||
Reference in New Issue
Block a user