http://bugs.winehq.org/show_bug.cgi?id=27339
--- Comment #3 from kevin.hendricks@sympatico.ca 2011-05-31 12:17:14 CDT --- Hi,
That same problem exists in GetUserNameA in that same file.
If I set too small a buffer and invoke GetUserNameA under Windows, it returns 122 "ERROR_INSUFFICIENT_BUFFER" and not 234 "ERROR_MORE_DATA".
Here is the problem snippet of code from GetUserNameA
53 BOOL WINAPI 54 GetUserNameA( LPSTR lpszName, LPDWORD lpSize ) 55 {
...
65 ret = GetUserNameW( buffer, &sizeW ); 66 if (ret) 67 { 68 if (!(*lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpszName, *lpSize, NULL, NULL ))) 69 { 70 *lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL ); 71 SetLastError( ERROR_MORE_DATA ); 72 ret = FALSE; 73 } 74 } 75 else *lpSize = sizeW * 2; 76 HeapFree( GetProcessHeap(), 0, buffer ); 77 return ret; 78 }
GetUserNameA knows to loop and double its own internal buffer size until it holds the username generated by GetUserNameW but still has to return "ERROR_INSUFFICIENT_BUFFER" to its caller to tell it to grow the size of its buffer to match otherwise there is no way to return the username value to the caller.
So "ERROR_MORE_DATA" should be changed to "ERROR_INSUFFICIENT_BUFFER" here as well to match what GetLastError on Windows returns for GetUserNameA.
If you need an modified python test program that shows this error, please let me know and I will attach it.