Check for invalid parameters in GetUserName
This commit is contained in:
parent
69bfc8906b
commit
e14934d06d
|
@ -11,6 +11,7 @@ const string utf8 = "UTF-8";
|
|||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724432(v=vs.85).aspx
|
||||
// Sets errno to:
|
||||
// ERROR_INVALID_PARAMETER - parameter is not valid
|
||||
// ERROR_BAD_ENVIRONMENT - locale is not UTF-8
|
||||
// ERROR_TOO_MANY_OPEN_FILES - already have the maximum allowed number of open files
|
||||
// ERROR_NO_ASSOCIATION - calling process has no controlling terminal
|
||||
|
@ -27,6 +28,12 @@ BOOL GetUserName(WCHAR_T* lpBuffer, LPDWORD lpnSize)
|
|||
{
|
||||
errno = 0;
|
||||
|
||||
// Check parameters
|
||||
if (!lpBuffer || !lpnSize) {
|
||||
errno = ERROR_INVALID_PARAMETER;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Select locale from environment
|
||||
setlocale(LC_ALL, "");
|
||||
// Check that locale is UTF-8
|
||||
|
|
Loading…
Reference in a new issue