setupapi: prevent page faults in SetupDiDeleteDeviceInterfaceRegKey

Christopher raccoonone at procyongames.com
Mon Mar 31 11:38:42 CDT 2008


wine-devel-request at winehq.org wrote:
> Message: 4 Date: Sun, 30 Mar 2008 19:13:46 -0600 From: Vitaliy 
> Margolen <wine-devel at kievinfo.com> Subject: Re: setupapi: prevent page 
> faults in SetupDiDeleteDeviceInterfaceRegKey To: wine-devel at winehq.org 
> Message-ID: <47F03ACA.5010308 at kievinfo.com> Content-Type: text/plain; 
> charset=ISO-8859-1; format=flowed 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.
Thanks for the comments! I found that Alexander Morozov's patches fix 
the same issue my patch was aimed at. After his are committed, I'll fix 
and resubmit mine if it's needed.

Christopher Berner



More information about the wine-devel mailing list