]> xenbits.xensource.com Git - pvdrivers/win/xenvkbd.git/commitdiff
Fix Length calculation in PdoQueryId
authorOwen Smith <owen.smith@cloud.com>
Mon, 2 Oct 2023 12:52:03 +0000 (13:52 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Mon, 2 Oct 2023 16:03:48 +0000 (17:03 +0100)
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 <owen.smith@cloud.com>
src/xenvkbd/pdo.c

index 3591e147943f8e06b9e6e2fc04766b83eabcbe25..256859f6122ce933ef2bd872240010368fc42874 100644 (file)
@@ -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;
         }