Check for out-of-bound accesses in the CoT description
The chain of trust array is now always accessed through a fconf getter.
This gives us an ideal spot to check for out-of-bound accesses.
Change-Id: Ic5ea20e43cf8ca959bb7f9b60de7c0839b390add
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
diff --git a/include/lib/fconf/fconf_tbbr_getter.h b/include/lib/fconf/fconf_tbbr_getter.h
index eddc0c4..db98b68 100644
--- a/include/lib/fconf/fconf_tbbr_getter.h
+++ b/include/lib/fconf/fconf_tbbr_getter.h
@@ -7,10 +7,15 @@
#ifndef FCONF_TBBR_GETTER_H
#define FCONF_TBBR_GETTER_H
+#include <assert.h>
+
#include <lib/fconf/fconf.h>
/* TBBR related getter */
-#define tbbr__cot_getter(id) cot_desc_ptr[id]
+#define tbbr__cot_getter(id) __extension__ ({ \
+ assert((id) < cot_desc_size); \
+ cot_desc_ptr[id]; \
+})
#define tbbr__dyn_config_getter(id) tbbr_dyn_config.id