提交 336c0dac 编写于 作者: Y yanmengzhao

check file before dlopen.

Signed-off-by: Nyanmengzhao <yanmengzhao1@huawei.com>
上级 ea98b5a8
......@@ -184,18 +184,20 @@ static void DoExec(const struct CmdArgs *ctx)
INIT_ERROR_CHECK(ctx != NULL && ctx->argv[0] != NULL, _exit(0x7f),
"DoExec: invalid arguments to exec \"%s\"", ctx->argv[0]);
#ifdef SUPPORT_PROFILER_HIDEBUG
void* handle = dlopen("/system/lib/libhidebug.so", RTLD_LAZY);
if (handle == NULL) {
INIT_LOGE("Failed to dlopen libhidebug.so, %s\n", dlerror());
return;
if (access("/system/lib/libhidebug.so", F_OK) == 0) {
void* handle = dlopen("/system/lib/libhidebug.so", RTLD_LAZY);
if (handle == NULL) {
INIT_LOGE("Failed to dlopen libhidebug.so, %s\n", dlerror());
return;
}
bool (* initParam)();
initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam");
if (initParam == NULL) {
INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror());
return;
}
(*initParam)(ctx->argv[0]);
}
bool (* initParam)();
initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam");
if (initParam == NULL) {
INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror());
return;
}
(*initParam)(ctx->argv[0]);
#endif
int ret = execv(ctx->argv[0], ctx->argv);
if (ret == -1) {
......
......@@ -19,6 +19,7 @@
#include <string.h>
#include <sys/param.h>
#include <sys/resource.h>
#include <unistd.h>
#include "init_group_manager.h"
#include "init.h"
......@@ -87,18 +88,20 @@ int ServiceExec(const Service *service)
}
INIT_CHECK_ONLY_ELOG(unsetenv("UV_THREADPOOL_SIZE") == 0, "set UV_THREADPOOL_SIZE error : %d.", errno);
#ifdef SUPPORT_PROFILER_HIDEBUG
void* handle = dlopen("/system/lib/libhidebug.so", RTLD_LAZY);
if (handle == NULL) {
INIT_LOGE("Failed to dlopen libhidebug.so, %s\n", dlerror());
return SERVICE_FAILURE;
}
bool (* initParam)();
initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam");
if (initParam == NULL) {
INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror());
return SERVICE_FAILURE;
if (access("/system/lib/libhidebug.so", F_OK) == 0) {
void* handle = dlopen("/system/lib/libhidebug.so", RTLD_LAZY);
if (handle == NULL) {
INIT_LOGE("Failed to dlopen libhidebug.so, %s\n", dlerror());
return SERVICE_FAILURE;
}
bool (* initParam)();
initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam");
if (initParam == NULL) {
INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror());
return SERVICE_FAILURE;
}
(*initParam)(service->name);
}
(*initParam)(service->name);
#endif
// L2 Can not be reset env
if (service->extraArgs.argv != NULL && service->extraArgs.count > 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册