Author: hpoussin
Date: Sat Nov 10 18:44:16 2007
New Revision: 30329
URL:
http://svn.reactos.org/svn/reactos?rev=30329&view=rev
Log:
Limit machine name size
Implement SetupDiGetDeviceInfoListDetailA
Rework SetupDiGetDeviceInfoListDetailW
Modified:
trunk/reactos/dll/win32/setupapi/cfgmgr.c
trunk/reactos/dll/win32/setupapi/devinst.c
trunk/reactos/dll/win32/setupapi/stubs.c
Modified: trunk/reactos/dll/win32/setupapi/cfgmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/cfgmgr.…
==============================================================================
--- trunk/reactos/dll/win32/setupapi/cfgmgr.c (original)
+++ trunk/reactos/dll/win32/setupapi/cfgmgr.c Sat Nov 10 18:44:16 2007
@@ -39,7 +39,7 @@
typedef struct _MACHINE_INFO
{
- WCHAR szMachineName[MAX_PATH];
+ WCHAR szMachineName[SP_MAX_MACHINENAME_LENGTH];
RPC_BINDING_HANDLE BindingHandle;
HSTRING_TABLE StringTable;
BOOL bLocal;
@@ -397,6 +397,11 @@
else
{
pMachine->bLocal = FALSE;
+ if (wcslen(UNCServerName) >= SP_MAX_MACHINENAME_LENGTH - 1)
+ {
+ HeapFree(GetProcessHeap(), 0, pMachine);
+ return CR_INVALID_MACHINENAME;
+ }
lstrcpyW(pMachine->szMachineName, UNCServerName);
pMachine->StringTable = StringTableInitialize();
Modified: trunk/reactos/dll/win32/setupapi/devinst.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/devinst…
==============================================================================
--- trunk/reactos/dll/win32/setupapi/devinst.c (original)
+++ trunk/reactos/dll/win32/setupapi/devinst.c Sat Nov 10 18:44:16 2007
@@ -176,7 +176,7 @@
DWORD size;
DWORD rc;
CONFIGRET cr;
- HDEVINFO ret = (HDEVINFO)INVALID_HANDLE_VALUE;;
+ HDEVINFO ret = (HDEVINFO)INVALID_HANDLE_VALUE;
TRACE("%s %p %s %p\n", debugstr_guid(ClassGuid), hwndParent,
debugstr_w(MachineName), Reserved);
@@ -189,7 +189,15 @@
size = FIELD_OFFSET(struct DeviceInfoSet, szData);
if (MachineName)
- size += (strlenW(MachineName) + 3) * sizeof(WCHAR);
+ {
+ SIZE_T len = strlenW(MachineName);
+ if (len >= SP_MAX_MACHINENAME_LENGTH - 4)
+ {
+ SetLastError(ERROR_INVALID_MACHINENAME);
+ goto cleanup;
+ }
+ size += (len + 3) * sizeof(WCHAR);
+ }
list = MyMalloc(size);
if (!list)
{
@@ -893,6 +901,90 @@
CM_Disconnect_Machine(list->hMachine);
DestroyClassInstallParams(&list->ClassInstallParams);
return HeapFree(GetProcessHeap(), 0, list);
+}
+
+/***********************************************************************
+ * SetupDiGetDeviceInfoListDetailA (SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiGetDeviceInfoListDetailA(
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_LIST_DETAIL_DATA_A DevInfoData )
+{
+ struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
+
+ TRACE("%p %p\n", DeviceInfoSet, DevInfoData);
+
+ if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+ if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+ if (!DevInfoData ||
+ DevInfoData->cbSize != sizeof(SP_DEVINFO_LIST_DETAIL_DATA_A))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ memcpy(
+ &DeviceInfoListDetailData->ClassGuid,
+ &list->ClassGuid,
+ sizeof(GUID));
+ DeviceInfoListDetailData->RemoteMachineHandle = list->hMachine;
+ if (list->MachineName)
+ {
+ FIXME("Stub\n");
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ return FALSE;
+ }
+ else
+ DeviceInfoListDetailData->RemoteMachineName[0] = 0;
+
+ return TRUE;
+}
+
+/***********************************************************************
+ * SetupDiGetDeviceInfoListDetailW (SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiGetDeviceInfoListDetailW(
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_LIST_DETAIL_DATA_W DevInfoData )
+{
+ struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
+
+ TRACE("%p %p\n", DeviceInfoSet, DevInfoData);
+
+ if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+ if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+ if (!DevInfoData ||
+ DevInfoData->cbSize != sizeof(SP_DEVINFO_LIST_DETAIL_DATA_W))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ memcpy(
+ &DeviceInfoListDetailData->ClassGuid,
+ &list->ClassGuid,
+ sizeof(GUID));
+ DeviceInfoListDetailData->RemoteMachineHandle = list->hMachine;
+ if (list->MachineName)
+ strcpyW(DeviceInfoListDetailData->RemoteMachineName, list->MachineName +
2);
+ else
+ DeviceInfoListDetailData->RemoteMachineName[0] = 0;
+
+ return TRUE;
}
/***********************************************************************
@@ -1754,46 +1846,6 @@
}
/***********************************************************************
- * SetupDiGetDeviceInfoListDetailW (SETUPAPI.@)
- */
-BOOL WINAPI
-SetupDiGetDeviceInfoListDetailW(
- IN HDEVINFO DeviceInfoSet,
- OUT PSP_DEVINFO_LIST_DETAIL_DATA_W DeviceInfoListDetailData)
-{
- struct DeviceInfoSet *list;
- BOOL ret = FALSE;
-
- TRACE("%p %p\n", DeviceInfoSet, DeviceInfoListDetailData);
-
- if (!DeviceInfoSet)
- SetLastError(ERROR_INVALID_HANDLE);
- else if ((list = (struct DeviceInfoSet *)DeviceInfoSet)->magic !=
SETUP_DEVICE_INFO_SET_MAGIC)
- SetLastError(ERROR_INVALID_HANDLE);
- else if (!DeviceInfoListDetailData)
- SetLastError(ERROR_INVALID_PARAMETER);
- else if (DeviceInfoListDetailData->cbSize !=
sizeof(SP_DEVINFO_LIST_DETAIL_DATA_W))
- SetLastError(ERROR_INVALID_USER_BUFFER);
- else
- {
- memcpy(
- &DeviceInfoListDetailData->ClassGuid,
- &list->ClassGuid,
- sizeof(GUID));
- DeviceInfoListDetailData->RemoteMachineHandle = list->hMachine;
- if (list->MachineName)
- strcpyW(DeviceInfoListDetailData->RemoteMachineName, list->MachineName
+ 2);
- else
- DeviceInfoListDetailData->RemoteMachineName[0] = 0;
-
- ret = TRUE;
- }
-
- TRACE("Returning %d\n", ret);
- return ret;
-}
-
-/***********************************************************************
* SetupDiGetDeviceInstallParamsA (SETUPAPI.@)
*/
BOOL WINAPI
Modified: trunk/reactos/dll/win32/setupapi/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/stubs.c…
==============================================================================
--- trunk/reactos/dll/win32/setupapi/stubs.c (original)
+++ trunk/reactos/dll/win32/setupapi/stubs.c Sat Nov 10 18:44:16 2007
@@ -42,98 +42,21 @@
}
/***********************************************************************
- * SetupDiGetDeviceInfoListDetailA (SETUPAPI.@)
- */
-BOOL WINAPI SetupDiGetDeviceInfoListDetailA(HDEVINFO devinfo,
PSP_DEVINFO_LIST_DETAIL_DATA_A devinfo_data )
-{
- FIXME("\n");
- return FALSE;
-}
-
-/***********************************************************************
* SetupInitializeFileLogW(SETUPAPI.@)
*/
-HANDLE WINAPI SetupInitializeFileLogW(LPCWSTR LogFileName, DWORD Flags)
+HSPFILELOG WINAPI SetupInitializeFileLogW(LPCWSTR LogFileName, DWORD Flags)
{
- FIXME("Stub %s, 0x%lx\n",debugstr_w(LogFileName),Flags);
+ FIXME("Stub %s, 0x%x\n",debugstr_w(LogFileName),Flags);
return INVALID_HANDLE_VALUE;
}
/***********************************************************************
* SetupInitializeFileLogA(SETUPAPI.@)
*/
-HANDLE WINAPI SetupInitializeFileLogA(LPCSTR LogFileName, DWORD Flags)
+HSPFILELOG WINAPI SetupInitializeFileLogA(LPCSTR LogFileName, DWORD Flags)
{
- FIXME("Stub %s, 0x%lx\n",debugstr_a(LogFileName),Flags);
+ FIXME("Stub %s, 0x%x\n",debugstr_a(LogFileName),Flags);
return INVALID_HANDLE_VALUE;
-}
-
-/***********************************************************************
- * SetupPromptReboot(SETUPAPI.@)
- */
-INT WINAPI SetupPromptReboot(HSPFILEQ FileQueue, HWND Owner, BOOL ScanOnly)
-{
-#if 0
- int ret;
- TCHAR RebootText[RC_STRING_MAX_SIZE];
- TCHAR RebootCaption[RC_STRING_MAX_SIZE];
- INT rc = 0;
-
- TRACE("%p %p %d\n", FileQueue, Owner, ScanOnly);
-
- if (ScanOnly && !FileQueue)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return -1;
- }
-
- if (FileQueue)
- {
- FIXME("Case 'FileQueue != NULL' not implemented\n");
- /* In some cases, do 'rc |= SPFILEQ_FILE_IN_USE' */
- }
-
- if (ScanOnly)
- return rc;
-
- /* We need to ask the question to the user. */
- rc |= SPFILEQ_REBOOT_RECOMMENDED;
- if (0 == LoadString(hInstance, IDS_QUERY_REBOOT_TEXT, RebootText,
RC_STRING_MAX_SIZE))
- return -1;
- if (0 == LoadString(hInstance, IDS_QUERY_REBOOT_CAPTION, RebootCaption,
RC_STRING_MAX_SIZE))
- return -1;
- ret = MessageBox(Owner, RebootText, RebootCaption, MB_YESNO | MB_DEFBUTTON1);
- if (IDNO == ret)
- return rc;
- else
- {
- if (ExitWindowsEx(EWX_REBOOT, 0))
- return rc | SPFILEQ_REBOOT_IN_PROGRESS;
- else
- return -1;
- }
-#endif
- FIXME("Stub %p %p %d\n", FileQueue, Owner, ScanOnly);
- SetLastError(ERROR_GEN_FAILURE);
- return -1;
-}
-
-/***********************************************************************
- * SetupSetSourceListA (SETUPAPI.@)
- */
-BOOL WINAPI SetupSetSourceListA(DWORD flags, PCSTR *list, UINT count)
-{
- FIXME("0x%08lx %p %d\n", flags, list, count);
- return FALSE;
-}
-
-/***********************************************************************
- * SetupSetSourceListW (SETUPAPI.@)
- */
-BOOL WINAPI SetupSetSourceListW(DWORD flags, PCWSTR *list, UINT count)
-{
- FIXME("0x%08lx %p %d\n", flags, list, count);
- return FALSE;
}
/***********************************************************************
@@ -150,14 +73,14 @@
*/
BOOL WINAPI RegistryDelnode(DWORD x, DWORD y)
{
- FIXME("%08lx %08lx: stub\n", x, y);
+ FIXME("%08x %08x: stub\n", x, y);
return FALSE;
}
/***********************************************************************
* SetupCloseLog(SETUPAPI.@)
*/
-void WINAPI SetupCloseLog()
+void WINAPI SetupCloseLog(void)
{
FIXME("() stub\n");
}
@@ -165,9 +88,9 @@
/***********************************************************************
* SetupLogErrorW(SETUPAPI.@)
*/
-BOOL WINAPI SetupLogErrorW(PCWSTR MessageString, LogSeverity Severity)
+BOOL WINAPI SetupLogErrorW(LPCWSTR MessageString, LogSeverity Severity)
{
- FIXME("(%s, %ld) stub\n", debugstr_w(MessageString), Severity);
+ FIXME("(%s, %d) stub\n", debugstr_w(MessageString), Severity);
return TRUE;
}
@@ -178,6 +101,33 @@
{
FIXME("(%d) stub\n", Reserved);
return TRUE;
+}
+
+/***********************************************************************
+ * SetupPromptReboot(SETUPAPI.@)
+ */
+INT WINAPI SetupPromptReboot( HSPFILEQ file_queue, HWND owner, BOOL scan_only )
+{
+ FIXME("%p, %p, %d\n", file_queue, owner, scan_only);
+ return 0;
+}
+
+/***********************************************************************
+ * SetupSetSourceListA (SETUPAPI.@)
+ */
+BOOL WINAPI SetupSetSourceListA(DWORD flags, PCSTR *list, UINT count)
+{
+ FIXME("0x%08x %p %d\n", flags, list, count);
+ return FALSE;
+}
+
+/***********************************************************************
+ * SetupSetSourceListW (SETUPAPI.@)
+ */
+BOOL WINAPI SetupSetSourceListW(DWORD flags, PCWSTR *list, UINT count)
+{
+ FIXME("0x%08x %p %d\n", flags, list, count);
+ return FALSE;
}
/***********************************************************************