|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 11/11] xenvkbd: Add an ASSERT on the array bound in SetArray
Code analysis warns about the bounds of Array in the loop that shifts
the remaining keys down, but Idx + 1 always stays below Size there,
since the loop runs while Idx < Size - 1. Add an ASSERT stating it,
so that the analyzer knows the access is in bounds.
Signed-off-by: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
---
src/xenvkbd/ring.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/xenvkbd/ring.c b/src/xenvkbd/ring.c
index 7779b83..48b65fd 100644
--- a/src/xenvkbd/ring.c
+++ b/src/xenvkbd/ring.c
@@ -170,8 +170,10 @@ SetArray(
break;
if (Array[Idx] != Value)
continue;
- for (; Idx < Size - 1; ++Idx)
+ for (; Idx < Size - 1; ++Idx) {
+ ASSERT3U(Idx + 1, <, Size);
Array[Idx] = Array[Idx + 1];
+ }
Array[Size - 1] = 0;
break;
}
--
2.55.0.windows.5
--
Césaire Mounah | Vates Windows Guest Tools Engineer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |