提交 982544bd 编写于 作者: J jwz

use internal_calloc

Signed-off-by: Njwz <jiangweizheng@huawei.com>
上级 4e58b46a
...@@ -56,7 +56,7 @@ static char* get_native_hook_param() ...@@ -56,7 +56,7 @@ static char* get_native_hook_param()
{ {
#ifdef OHOS_ENABLE_PARAMETER #ifdef OHOS_ENABLE_PARAMETER
const char *key = MUSL_HOOK_PARAM_NAME; const char *key = MUSL_HOOK_PARAM_NAME;
char *value = (char *)calloc(OHOS_PARAM_MAX_SIZE, sizeof(char)); char *value = (char *)internal_calloc(OHOS_PARAM_MAX_SIZE, sizeof(char));
if (value == NULL) { if (value == NULL) {
return NULL; return NULL;
} }
...@@ -118,7 +118,7 @@ static int parse_hook_variable(enum EnumHookMode* mode, char* path, int size) ...@@ -118,7 +118,7 @@ static int parse_hook_variable(enum EnumHookMode* mode, char* path, int size)
} }
} }
free(hook_param_value); internal_free(hook_param_value);
} }
__set_hook_flag(flag); __set_hook_flag(flag);
return 0; return 0;
...@@ -129,9 +129,8 @@ static bool get_proc_name(pid_t pid, char *buf, unsigned int buf_len) ...@@ -129,9 +129,8 @@ static bool get_proc_name(pid_t pid, char *buf, unsigned int buf_len)
if (pid <= 0) { if (pid <= 0) {
return false; return false;
} }
const int file_name_max_size = 40; char target_file[FILE_NAME_MAX_SIZE] = {0};
char target_file[file_name_max_size] = {0}; (void)snprintf(target_file, sizeof(target_file), "/proc/%d/cmdline", pid);
(void)sprintf(target_file, "/proc/%d/cmdline", pid);
FILE *f = fopen(target_file, "r"); FILE *f = fopen(target_file, "r");
if (f == NULL) { if (f == NULL) {
return false; return false;
......
...@@ -109,6 +109,7 @@ inline volatile const struct MallocDispatchType* get_current_dispatch_table() ...@@ -109,6 +109,7 @@ inline volatile const struct MallocDispatchType* get_current_dispatch_table()
#define MUSL_HOOK_PARAM_NAME "libc.hook_mode" #define MUSL_HOOK_PARAM_NAME "libc.hook_mode"
#define OHOS_PARAM_MAX_SIZE 96 #define OHOS_PARAM_MAX_SIZE 96
#define FILE_NAME_MAX_SIZE 40
#ifdef __cplusplus #ifdef __cplusplus
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册