Set the size of the channel property arrays

Arrays which don't initialize the last elements of the enumeration are
shorter and will cause a buffer overflow when read in a loop.
This commit is contained in:
Rodrigo Arias 2023-04-24 12:19:15 +02:00
parent 8a92023cf3
commit c2b6bfd3a8
7 changed files with 12 additions and 12 deletions

View File

@ -18,7 +18,7 @@
#include "value.h" #include "value.h"
static const char chan_fmt[] = "cpu%ld.%s"; static const char chan_fmt[] = "cpu%ld.%s";
static const char *chan_name[] = { static const char *chan_name[CPU_CHAN_MAX] = {
[CPU_CHAN_NRUN] = "nrunning", [CPU_CHAN_NRUN] = "nrunning",
[CPU_CHAN_PID] = "pid_running", [CPU_CHAN_PID] = "pid_running",
[CPU_CHAN_TID] = "tid_running", [CPU_CHAN_TID] = "tid_running",
@ -26,7 +26,7 @@ static const char *chan_name[] = {
[CPU_CHAN_THACT] = "th_active", [CPU_CHAN_THACT] = "th_active",
}; };
static int chan_type[] = { static int chan_type[CPU_CHAN_MAX] = {
[CPU_CHAN_PID] = PRV_CPU_PID, [CPU_CHAN_PID] = PRV_CPU_PID,
[CPU_CHAN_TID] = PRV_CPU_TID, [CPU_CHAN_TID] = PRV_CPU_TID,
[CPU_CHAN_NRUN] = PRV_CPU_NRUN, [CPU_CHAN_NRUN] = PRV_CPU_NRUN,
@ -34,7 +34,7 @@ static int chan_type[] = {
[CPU_CHAN_THACT] = -1, [CPU_CHAN_THACT] = -1,
}; };
static long prv_flags[] = { static long prv_flags[CPU_CHAN_MAX] = {
[CPU_CHAN_NRUN] = PRV_ZERO, [CPU_CHAN_NRUN] = PRV_ZERO,
}; };

View File

@ -40,7 +40,7 @@ static const int chan_stack[CH_MAX] = {
/* ----------------- pvt ------------------ */ /* ----------------- pvt ------------------ */
static const int pvt_type[] = { static const int pvt_type[CH_MAX] = {
[CH_CS] = PRV_KERNEL_CS, [CH_CS] = PRV_KERNEL_CS,
}; };

View File

@ -65,7 +65,7 @@ static const int chan_dup[CH_MAX] = {
/* ----------------- pvt ------------------ */ /* ----------------- pvt ------------------ */
static const int pvt_type[] = { static const int pvt_type[CH_MAX] = {
[CH_TASKID] = PRV_NANOS6_TASKID, [CH_TASKID] = PRV_NANOS6_TASKID,
[CH_TYPE] = PRV_NANOS6_TYPE, [CH_TYPE] = PRV_NANOS6_TYPE,
[CH_SUBSYSTEM] = PRV_NANOS6_SUBSYSTEM, [CH_SUBSYSTEM] = PRV_NANOS6_SUBSYSTEM,

View File

@ -46,7 +46,7 @@ static const int chan_stack[CH_MAX] = {
/* ----------------- pvt ------------------ */ /* ----------------- pvt ------------------ */
static const int pvt_type[] = { static const int pvt_type[CH_MAX] = {
[CH_SUBSYSTEM] = PRV_NODES_SUBSYSTEM, [CH_SUBSYSTEM] = PRV_NODES_SUBSYSTEM,
}; };

View File

@ -61,7 +61,7 @@ static const int chan_dup[CH_MAX] = {
/* ----------------- pvt ------------------ */ /* ----------------- pvt ------------------ */
static const int pvt_type[] = { static const int pvt_type[CH_MAX] = {
[CH_TASKID] = PRV_NOSV_TASKID, [CH_TASKID] = PRV_NOSV_TASKID,
[CH_TYPE] = PRV_NOSV_TYPE, [CH_TYPE] = PRV_NOSV_TYPE,
[CH_APPID] = PRV_NOSV_APPID, [CH_APPID] = PRV_NOSV_APPID,

View File

@ -40,7 +40,7 @@ static const int chan_stack[CH_MAX] = { 0 };
/* ----------------- pvt ------------------ */ /* ----------------- pvt ------------------ */
static const int pvt_type[] = { static const int pvt_type[CH_MAX] = {
[CH_FLUSH] = PRV_OVNI_FLUSH, [CH_FLUSH] = PRV_OVNI_FLUSH,
}; };

View File

@ -19,19 +19,19 @@
struct proc; struct proc;
static const char chan_fmt[] = "thread%lu.%s"; static const char chan_fmt[] = "thread%lu.%s";
static const char *chan_name[] = { static const char *chan_name[TH_CHAN_MAX] = {
[TH_CHAN_CPU] = "cpu_gindex", [TH_CHAN_CPU] = "cpu_gindex",
[TH_CHAN_TID] = "tid_active", [TH_CHAN_TID] = "tid_active",
[TH_CHAN_STATE] = "state", [TH_CHAN_STATE] = "state",
}; };
static const int chan_type[] = { static const int chan_type[TH_CHAN_MAX] = {
[TH_CHAN_CPU] = PRV_THREAD_CPU, [TH_CHAN_CPU] = PRV_THREAD_CPU,
[TH_CHAN_TID] = PRV_THREAD_TID, [TH_CHAN_TID] = PRV_THREAD_TID,
[TH_CHAN_STATE] = PRV_THREAD_STATE, [TH_CHAN_STATE] = PRV_THREAD_STATE,
}; };
static const long prv_flags[] = { static const long prv_flags[TH_CHAN_MAX] = {
/* Add one to the zero-based cpu gindex */ /* Add one to the zero-based cpu gindex */
[TH_CHAN_CPU] = PRV_NEXT, [TH_CHAN_CPU] = PRV_NEXT,
@ -40,7 +40,7 @@ static const long prv_flags[] = {
[TH_CHAN_STATE] = PRV_SKIPDUP, [TH_CHAN_STATE] = PRV_SKIPDUP,
}; };
static const char *pvt_name[] = { static const char *pvt_name[TH_CHAN_MAX] = {
[TH_CHAN_CPU] = "Thread: CPU affinity", [TH_CHAN_CPU] = "Thread: CPU affinity",
[TH_CHAN_TID] = "Thread: TID of the ACTIVE thread", [TH_CHAN_TID] = "Thread: TID of the ACTIVE thread",
[TH_CHAN_STATE] = "Thread: thread state", [TH_CHAN_STATE] = "Thread: thread state",