From 74b473483a16822268184986a1a112eb4cd41b13 Mon Sep 17 00:00:00 2001 From: chengjinsong Date: Mon, 24 Oct 2022 17:26:58 +0800 Subject: [PATCH] codex Signed-off-by: chengjinsong --- services/modules/reboot/reboot_static.c | 3 +++ test/moduletest/param_test_cmds.c | 1 + test/unittest/init/loopevent_unittest.cpp | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/modules/reboot/reboot_static.c b/services/modules/reboot/reboot_static.c index 7263ffbe..70ddb34d 100644 --- a/services/modules/reboot/reboot_static.c +++ b/services/modules/reboot/reboot_static.c @@ -24,6 +24,7 @@ #define REBOOT_NAME_PREFIX "reboot," #define REBOOT_CMD_PREFIX "reboot." #define REBOOT_REPLACE_PREFIX "reboot." +#define PARAM_CMD_MAX 100 static int RebootHookWrapper(const HOOK_INFO *hookInfo, void *executionContext) { @@ -111,6 +112,7 @@ static int SetParamCmdInfo(ParamCmdInfo *currInfo, CmdExecutor executor, const c static int AddRebootCmdExecutor_(const char *cmd, CmdExecutor executor) { + PLUGIN_CHECK(g_rebootParamCmdMaxNumber <= PARAM_CMD_MAX, return -1, "Param cmd max number exceed limit"); if (g_rebootParamCmdMaxNumber == 0 || g_rebootParamCmdMaxNumber <= g_rebootParamCmdValidNumber) { g_rebootParamCmdMaxNumber += 5; // inc 5 once time ParamCmdInfo *cmdInfos = calloc(1, sizeof(ParamCmdInfo) * g_rebootParamCmdMaxNumber); @@ -126,6 +128,7 @@ static int AddRebootCmdExecutor_(const char *cmd, CmdExecutor executor) } g_rebootParamCmdInfos = cmdInfos; } + PLUGIN_CHECK(g_rebootParamCmdValidNumber < g_rebootParamCmdMaxNumber, return -1, "Param cmd number exceed limit"); return SetParamCmdInfo(&g_rebootParamCmdInfos[g_rebootParamCmdValidNumber], executor, cmd); } diff --git a/test/moduletest/param_test_cmds.c b/test/moduletest/param_test_cmds.c index 7aab9a77..56453c12 100644 --- a/test/moduletest/param_test_cmds.c +++ b/test/moduletest/param_test_cmds.c @@ -295,6 +295,7 @@ static int32_t BShellParamCmdMemGet(BShellHandle shell, int32_t argc, char *argv PLUGIN_CHECK(argc > 1, return -1, "Invalid parameter"); uint32_t buffSize = 0; // 1024 max buffer for decode char *buff = GetLocalBuffer(&buffSize); + PLUGIN_CHECK(buff != NULL, return -1, "Failed to get local buffer"); int ret = sprintf_s(buff, buffSize - 1, "/proc/%s/smaps", argv[1]); PLUGIN_CHECK(ret > 0, return -1, "Failed to format path %s", argv[1]); buff[ret] = '\0'; diff --git a/test/unittest/init/loopevent_unittest.cpp b/test/unittest/init/loopevent_unittest.cpp index e2b4afaa..8f4d18a4 100644 --- a/test/unittest/init/loopevent_unittest.cpp +++ b/test/unittest/init/loopevent_unittest.cpp @@ -201,8 +201,8 @@ public: if (task != nullptr) { task->handleEvent = TestHandleTaskEvent; ProcessEvent((EventLoop *)LE_GetDefaultLoop(), testfd, Event_Read); + ((HashTab *)(((EventLoop *)LE_GetDefaultLoop())->taskMap))->nodeFree(&task->hashNode); } - ((HashTab *)(((EventLoop *)LE_GetDefaultLoop())->taskMap))->nodeFree(&task->hashNode); } void ProcessasynEvent() { -- GitLab