setupapi: prevent page faults in SetupDiDeleteDeviceInterfaceRegKey

Vitaliy Margolen wine-devel at kievinfo.com
Sun Mar 30 20:13:46 CDT 2008


Christopher wrote:
> Changelog:
> Check that the handle and pointer passed to 
> SetupDiDeleteDeviceInterfaceRegKey are valid to read from. This patch 
> continues to address bug #12242
> 
> -    if (!DeviceInterfaceData ||
> +    if (!DeviceInterfaceData || IsBadReadPtr(DeviceInterfaceData, sizeof(SP_DEVICE_INTERFACE_DATA)) ||

Don't ever use IsBadReadPtr and IsBadWritePtr functions. They are bad and
even MS stopped using them. You have to use TRY-EXCEPT block around an
access to the memory. For example see implementation of lstrcpyA
(kernel32/string.c: 359).

> +    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Expected SetupDiDeleteDeviceInterfaceRegKey to return FALSE, got %s, \
> +with error code: 6, got %d\n", ret ? "TRUE" : "FALSE", GetLastError());

This is bad way to split strings in c. Do something like this:

    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
	"Expected SetupDiDeleteDeviceInterfaceRegKey to return FALSE, got %s, "
	"with error code: 6, got %d\n", ret ? "TRUE" : "FALSE", GetLastError());

Vitaliy.



More information about the wine-devel mailing list