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>
diff --git a/common/event.c b/common/event.c
index dc61b96..16c2ba6 100644
--- a/common/event.c
+++ b/common/event.c
@@ -56,7 +56,10 @@
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