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

Hans Leidekker hans at codeweavers.com
Tue May 31 02:17:07 CDT 2011


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.





More information about the wine-devel mailing list