Don't write outside the array in SetupDiGetClassDevPropertySheetsW
authorHervé Poussineau <hpoussin@reactos.org>
Thu, 1 Dec 2005 10:52:16 +0000 (10:52 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Thu, 1 Dec 2005 10:52:16 +0000 (10:52 +0000)
svn path=/trunk/; revision=19794

reactos/lib/setupapi/devinst.c

index def6e52..10d85c1 100644 (file)
@@ -3733,14 +3733,14 @@ BOOL WINAPI SetupDiGetClassDevPropertySheetsW(
         Request.DeviceInfoSet = DeviceInfoSet;
         Request.DeviceInfoData = DeviceInfoData;
         PropPageData.PropertySheetPages = &PropertySheetHeader->phpage[PropertySheetHeader->nPages];
-        PropPageData.MaximumNumberOfPages = PropertySheetHeaderPageListSize;
+        PropPageData.MaximumNumberOfPages = PropertySheetHeaderPageListSize - PropertySheetHeader->nPages;
         PropPageData.NumberOfPages = 0;
         ret = pPropPageProvider(&Request, GetClassDevPropertySheetsCallback, (LPARAM)&PropPageData);
         if (!ret)
             goto cleanup;
 
         if (RequiredSize)
-            *RequiredSize = PropPageData.NumberOfPages;
+            *RequiredSize = PropPageData.NumberOfPages + PropertySheetHeader->nPages;
         if (PropPageData.NumberOfPages <= PropPageData.MaximumNumberOfPages)
         {
             PropertySheetHeader->nPages += PropPageData.NumberOfPages;