From e272264cb2f9218f30d069654474714a769fc973 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Tue, 27 Aug 2013 17:00:47 +0200 Subject: [PATCH] regulator & arndale: prevent invalid array index fix #831 --- os/include/platform/arndale/regulator/consts.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/os/include/platform/arndale/regulator/consts.h b/os/include/platform/arndale/regulator/consts.h index 80264a25c..4e8af4d29 100644 --- a/os/include/platform/arndale/regulator/consts.h +++ b/os/include/platform/arndale/regulator/consts.h @@ -49,14 +49,14 @@ namespace Regulator { Regulator_id regulator_id_by_name(const char * name) { - for (unsigned i = 0; i < MAX; i++) + for (unsigned i = 0; i < sizeof(names)/sizeof(names[0]); i++) if (Genode::strcmp(names[i].name, name) == 0) return names[i].id; return INVALID; } const char * regulator_name_by_id(Regulator_id id) { - return (id < MAX) ? names[id].name : 0; } + return (id < sizeof(names)/sizeof(names[0])) ? names[id].name : 0; } /***************************************