mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 00:27:13 +00:00
[SETUPAPI]
- remove logically dead code in SetupDiGetClassImageIndex, CID 500046 - prevent null pointer dereference in SetupDiGetClassDevPropertySheetsA, CID 500676 - use strsafe functions in SETUP_CreateDevicesListFromEnumerator, CID 514263 - fix a check and adjust the logic in SetupDiLoadClassIcon to remove dead code and possible null pointer dereference CID 1250279, CID 1250287 svn path=/trunk/; revision=73669
This commit is contained in:
parent
1014d132dc
commit
49f2678311
1 changed files with 22 additions and 17 deletions
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <wingdi.h>
|
#include <wingdi.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
|
||||||
/* Unicode constants */
|
/* Unicode constants */
|
||||||
static const WCHAR BackSlash[] = {'\\',0};
|
static const WCHAR BackSlash[] = {'\\',0};
|
||||||
|
@ -164,10 +165,16 @@ SETUP_CreateDevicesListFromEnumerator(
|
||||||
rc = RegOpenKeyExW(hEnumeratorKey, KeyBuffer, 0, KEY_ENUMERATE_SUB_KEYS, &hDeviceIdKey);
|
rc = RegOpenKeyExW(hEnumeratorKey, KeyBuffer, 0, KEY_ENUMERATE_SUB_KEYS, &hDeviceIdKey);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
strcpyW(InstancePath, Enumerator);
|
|
||||||
strcatW(InstancePath, BackSlash);
|
if (FAILED(StringCbCopyW(InstancePath, _countof(InstancePath), Enumerator)) ||
|
||||||
strcatW(InstancePath, KeyBuffer);
|
FAILED(StringCbCatW(InstancePath, _countof(InstancePath), BackSlash)) ||
|
||||||
strcatW(InstancePath, BackSlash);
|
FAILED(StringCbCatW(InstancePath, _countof(InstancePath), KeyBuffer)) ||
|
||||||
|
FAILED(StringCbCatW(InstancePath, _countof(InstancePath), BackSlash)))
|
||||||
|
{
|
||||||
|
rc = ERROR_GEN_FAILURE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
pEndOfInstancePath = &InstancePath[strlenW(InstancePath)];
|
pEndOfInstancePath = &InstancePath[strlenW(InstancePath)];
|
||||||
|
|
||||||
/* Enumerate instance IDs (subkeys of hDeviceIdKey) */
|
/* Enumerate instance IDs (subkeys of hDeviceIdKey) */
|
||||||
|
@ -406,8 +413,6 @@ SetupDiGetClassImageIndex(
|
||||||
SetLastError(ERROR_INVALID_USER_BUFFER);
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
||||||
else if (list->magic != SETUP_CLASS_IMAGE_LIST_MAGIC)
|
else if (list->magic != SETUP_CLASS_IMAGE_LIST_MAGIC)
|
||||||
SetLastError(ERROR_INVALID_USER_BUFFER);
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
||||||
else if (!ImageIndex)
|
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DWORD i;
|
DWORD i;
|
||||||
|
@ -784,13 +789,9 @@ SetupDiLoadClassIcon(
|
||||||
if (LargeIcon)
|
if (LargeIcon)
|
||||||
{
|
{
|
||||||
if(!SETUP_GetClassIconInfo(ClassGuid, &iconIndex, &DllName))
|
if(!SETUP_GetClassIconInfo(ClassGuid, &iconIndex, &DllName))
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
|
|
||||||
if (DllName && ExtractIconExW(DllName, -iconIndex, &hIcon, NULL, 1) == 1 && hIcon != NULL)
|
if (!DllName || ExtractIconExW(DllName, -iconIndex, &hIcon, NULL, 1) != 1 || hIcon == NULL)
|
||||||
{
|
|
||||||
ret = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* load the default unknown device icon if ExtractIcon failed */
|
/* load the default unknown device icon if ExtractIcon failed */
|
||||||
if(DllName)
|
if(DllName)
|
||||||
|
@ -798,16 +799,17 @@ SetupDiLoadClassIcon(
|
||||||
|
|
||||||
hIcon = LoadImage(hInstance, MAKEINTRESOURCE(iconIndex), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
|
hIcon = LoadImage(hInstance, MAKEINTRESOURCE(iconIndex), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
|
||||||
|
|
||||||
if(!LargeIcon)
|
if(!hIcon)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*LargeIcon = hIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MiniIconIndex)
|
if (MiniIconIndex)
|
||||||
*MiniIconIndex = iconIndex;
|
*MiniIconIndex = iconIndex;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
*LargeIcon = hIcon;
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
||||||
|
@ -1180,9 +1182,12 @@ SetupDiGetClassDevPropertySheetsA(
|
||||||
PropertySheetHeader, PropertySheetHeaderPageListSize,
|
PropertySheetHeader, PropertySheetHeaderPageListSize,
|
||||||
RequiredSize, PropertySheetType);
|
RequiredSize, PropertySheetType);
|
||||||
|
|
||||||
|
if(PropertySheetHeader)
|
||||||
|
{
|
||||||
psh.dwFlags = PropertySheetHeader->dwFlags;
|
psh.dwFlags = PropertySheetHeader->dwFlags;
|
||||||
psh.phpage = PropertySheetHeader->phpage;
|
psh.phpage = PropertySheetHeader->phpage;
|
||||||
psh.nPages = PropertySheetHeader->nPages;
|
psh.nPages = PropertySheetHeader->nPages;
|
||||||
|
}
|
||||||
|
|
||||||
ret = SetupDiGetClassDevPropertySheetsW(DeviceInfoSet, DeviceInfoData, PropertySheetHeader ? &psh : NULL,
|
ret = SetupDiGetClassDevPropertySheetsW(DeviceInfoSet, DeviceInfoData, PropertySheetHeader ? &psh : NULL,
|
||||||
PropertySheetHeaderPageListSize, RequiredSize,
|
PropertySheetHeaderPageListSize, RequiredSize,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue