From beb8bf498c681c886daefdddbd0b9e0f313bad2f Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 7 Jan 2020 17:45:44 +0100 Subject: [PATCH] base-hw: add explicit array-bounds check This patch rules out out-of-bounds array accesses without inspecting the caller. It is not a bug fix but adds clarity. --- repos/base-hw/src/include/hw/spec/arm/page_table.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/repos/base-hw/src/include/hw/spec/arm/page_table.h b/repos/base-hw/src/include/hw/spec/arm/page_table.h index 1c9a91df9..8f1a39c9d 100644 --- a/repos/base-hw/src/include/hw/spec/arm/page_table.h +++ b/repos/base-hw/src/include/hw/spec/arm/page_table.h @@ -422,6 +422,9 @@ class Hw::Page_table size_t const size, Page_flags const & flags, Allocator & alloc) { + if (i > MAX_INDEX) + return; + using Pt = Page_table_level_2; using Ptd = Page_table_descriptor;