advapi: test and fix GetUserName() in case where buffer is too small

Andrew Nguyen anguyen at codeweavers.com
Tue May 31 06:32:57 CDT 2011


On 05/31/2011 02:17 AM, Hans Leidekker wrote:
> On Mon, 2011-05-30 at 21:13 -0700, Dan Kegel wrote:
> 
>> @@ -91,7 +91,7 @@ GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
>>  
>>      if (len > *lpSize)
>>      {
>> -        SetLastError(ERROR_MORE_DATA);
>> +        SetLastError(ERROR_INSUFFICIENT_BUFFER);
> 
> GetUserNameA also needs to be fixed. It sets ERROR_MORE_DATA when
> WideCharToMultiByte fails, which can simply be removed because that
> function will set ERROR_INSUFFICIENT_BUFFER itself if the buffer is too
> small.
> 
> And there are at least two cases, in dlls/crypt32/protectdata.c and
> dlls/msi/package.c, where we depend on the wrong error.
> 
> 
> 
> 

I didn't intend to scoop Dan's work, but I have a version of his fix,
which is attached, with deeper tests which I wrote before Hans expressed
his concerns. Should I just send in the tests with todo_wine and let Dan
fix those, or should I send a revised version and allow a "winner" to be
picked?
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-advapi32-Fix-last-error-value-of-GetUserNameA-W-and-ou.txt
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20110531/1feb4b9f/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20110531/1feb4b9f/attachment.pgp>


More information about the wine-devel mailing list