From: Owen Smith Date: Mon, 2 Oct 2023 12:52:03 +0000 (+0100) Subject: Fix Length calculation in PdoQueryId X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c8f2c59b8ca55bf79d299c29f6af36c60b0a5736;p=pvdrivers%2Fwin%2Fxenvkbd.git Fix Length calculation in PdoQueryId Decrease Length by the string length of the current ID before moving the Buffer value to the end of the current ID. Without this, Length is not decreased, leading to potential issues with the next call to RtlStringCbPrintfW. Note: the second chunk it to maintain consistent ordering of operations for clarity, and has no functional change. Signed-off-by: Owen Smith --- diff --git a/src/xenvkbd/pdo.c b/src/xenvkbd/pdo.c index 3591e14..256859f 100644 --- a/src/xenvkbd/pdo.c +++ b/src/xenvkbd/pdo.c @@ -1356,11 +1356,11 @@ PdoQueryId( Revision->Number); ASSERT(NT_SUCCESS(status)); - Buffer += wcslen(Buffer); Length -= (ULONG)(wcslen(Buffer) * sizeof (WCHAR)); + Buffer += wcslen(Buffer); - Buffer++; Length -= sizeof (WCHAR); + Buffer++; --Index; }