Fix svace issue : kdbg_stackopt array index error
Buffer '&stkmon_arr' of size 64 accessed at kdbg_stackopt.c:124 can overflow, since its index 'stkmon_idx' can have value 64
that is out of range, as indicated by preceding conditional expression at kdbg_stackopt.c:114.
@@ -113,10 +113,6 @@ static void print_measure_result(pid_t pid, int argc, char **args)
int stkmon_idx;
for (stkmon_idx = 0; stkmon_idx < CONFIG_MAX_TASKS * 2; stkmon_idx++) {
if (stkmon_arr[stkmon_idx].chk_pid == pid) {
- break;
- }
- }
-
printf("---------------------------------------------------------------\n");
printf(">> Stack Size Measure Finish\n");
printf("APP Name : %s\n", stkmon_arr[stkmon_idx].chk_name);
@@ -126,6 +122,10 @@ static void print_measure_result(pid_t pid, int argc, char **args)
printf("---------------------------------------------------------------\n");
return;
}
+ }
+ printf("[ERROR] Cannot find the app\n");
+ return;
+}
int kdbg_stackopt(int argc, char **args)
{
