[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


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
  • Date: Mon, 19 Oct 2026 15:14:37 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
  • Cc: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
  • Delivery-date: Mon, 19 Oct 2026 13:14:55 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.