plugin_framewor, support plugin signature verification

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-05-16 09:48:33 +08:00
parent d417149949
commit 522f6f3309
3 changed files with 181 additions and 64 deletions

View File

@@ -1,4 +1,4 @@
use hbb_common::{libc, log, ResultType};
use hbb_common::{bail, libc, log, ResultType};
#[cfg(target_os = "windows")]
use std::env;
use std::{
@@ -133,6 +133,10 @@ fn get_plugin_dir(id: &str) -> ResultType<PathBuf> {
#[inline]
fn cstr_to_string(cstr: *const c_char) -> ResultType<String> {
assert!(!cstr.is_null(), "cstr must be a valid pointer");
if cstr.is_null() {
bail!("failed to convert string, the pointer is null");
}
Ok(String::from_utf8(unsafe {
CStr::from_ptr(cstr).to_bytes().to_vec()
})?)