diff options
author | Heinrich Schuchardt | 2024-01-28 08:58:55 +0100 |
---|---|---|
committer | Tom Rini | 2024-02-06 16:31:06 -0500 |
commit | 0c5110ccf83c2e9c3190e501855c49ee168a7239 (patch) | |
tree | 28d41cb94dce0a869a5f6519db902f6b80a8dd88 /common/event.c | |
parent | dd0807804ecdc10fdc22fdb9f0ff9889f5fc4b08 (diff) |
common: event: check event_type_name() argument
In event_type_name() we should avoid possible buffer overruns by checking
the type argument.
Addresses-Coverity-ID: 478862 Out-of-bounds access
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'common/event.c')
-rw-r--r-- | common/event.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/common/event.c b/common/event.c index dc61b9672f3..16c2ba6cc92 100644 --- a/common/event.c +++ b/common/event.c @@ -56,7 +56,10 @@ _Static_assert(ARRAY_SIZE(type_name) == EVT_COUNT, "event type_name size"); const char *event_type_name(enum event_t type) { #if CONFIG_IS_ENABLED(EVENT_DEBUG) - return type_name[type]; + if (type < ARRAY_SIZE(type_name)) + return type_name[type]; + else + return "(unknown)"; #else return "(unknown)"; #endif |