diff options
author | Jan Kotas <jkotas@microsoft.com> | 2016-01-25 11:35:54 -0800 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2016-01-25 11:35:54 -0800 |
commit | 525c7be46158b83bcbf171d89a0b7cf2c85fb829 (patch) | |
tree | a32e5188061c10699d183af85fe691e84074d608 | |
parent | 42a57adf75ca5195a79f47e1269d5e9ff214d7c4 (diff) | |
parent | d27273525d7fb7361f7577d373a1e82e9eae884d (diff) | |
download | coreclr-525c7be46158b83bcbf171d89a0b7cf2c85fb829.tar.gz coreclr-525c7be46158b83bcbf171d89a0b7cf2c85fb829.tar.bz2 coreclr-525c7be46158b83bcbf171d89a0b7cf2c85fb829.zip |
Merge pull request #2832 from Priya91/includefiles
Add identity.cpp to build.
-rw-r--r-- | src/dlls/mscoree/mscorwks_unixexports.src | 1 | ||||
-rw-r--r-- | src/pal/src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/pal/src/misc/identity.cpp | 14 | ||||
-rw-r--r-- | src/pal/tests/palsuite/miscellaneous/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/test.c | 7 | ||||
-rw-r--r-- | src/pal/tests/palsuite/paltestlist.txt | 1 |
6 files changed, 12 insertions, 13 deletions
diff --git a/src/dlls/mscoree/mscorwks_unixexports.src b/src/dlls/mscoree/mscorwks_unixexports.src index fe4f2a4350..7120337177 100644 --- a/src/dlls/mscoree/mscorwks_unixexports.src +++ b/src/dlls/mscoree/mscorwks_unixexports.src @@ -43,6 +43,7 @@ FlushFileBuffers FormatMessageW FreeEnvironmentStringsW GetACP +GetComputerNameW GetConsoleCP GetConsoleOutputCP GetCurrentDirectoryW diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt index 5fa87cc14d..b411cd4ec0 100644 --- a/src/pal/src/CMakeLists.txt +++ b/src/pal/src/CMakeLists.txt @@ -139,6 +139,7 @@ set(SOURCES misc/error.cpp misc/errorstrings.cpp misc/fmtmessage.cpp + misc/identity.cpp misc/miscpalapi.cpp misc/msgbox.cpp misc/strutil.cpp diff --git a/src/pal/src/misc/identity.cpp b/src/pal/src/misc/identity.cpp index 6be3c9d8ac..498ad49dcd 100644 --- a/src/pal/src/misc/identity.cpp +++ b/src/pal/src/misc/identity.cpp @@ -167,7 +167,7 @@ GetUserNameW( while (NULL == pPasswd) { - pchBuffer = (char*) InternalMalloc(pPalThread, sizeof(pchBuffer[0]) * dwBufLen); + pchBuffer = (char*) PAL_malloc(sizeof(pchBuffer[0]) * dwBufLen); if (NULL == pchBuffer) { pPalThread->SetLastError(ERROR_OUTOFMEMORY); @@ -182,7 +182,7 @@ GetUserNameW( if (ERANGE == iRet) // need a bigger buffer { - InternalFree(pPalThread, pchBuffer); + PAL_free(pchBuffer); pchBuffer = NULL; pPasswd = NULL; dwBufLen *= 2; // double the buffer @@ -274,12 +274,12 @@ done: #if HAVE_GETPWUID_R if (NULL != pchBuffer) { - InternalFree(pPalThread, pchBuffer); + PAL_free(pchBuffer); } #else // HAVE_GETPWUID_R if (NULL != szUserName) { - InternalFree(pPalThread, szUserName); + PAL_free(szUserName); } #endif // HAVE_GETPWUID_R @@ -343,12 +343,6 @@ GetComputerNameW( *pchDot = '\0'; // remove the domain name info } - // clip the hostname to MAX_COMPUTERNAME_LENGTH - if (sizeof(szHostName) > MAX_COMPUTERNAME_LENGTH) - { - szHostName[MAX_COMPUTERNAME_LENGTH] = '\0'; - } - // copy the hostname (including NULL character) cwchLen = MultiByteToWideChar(CP_ACP, 0, szHostName, -1, lpBuffer, *nSize); if (0 == cwchLen) diff --git a/src/pal/tests/palsuite/miscellaneous/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CMakeLists.txt index 800e303f14..86f194198b 100644 --- a/src/pal/tests/palsuite/miscellaneous/CMakeLists.txt +++ b/src/pal/tests/palsuite/miscellaneous/CMakeLists.txt @@ -8,6 +8,7 @@ add_subdirectory(FlushInstructionCache) add_subdirectory(FormatMessageW) add_subdirectory(FreeEnvironmentStringsW) add_subdirectory(GetCommandLineW) +add_subdirectory(GetComputerNameW) add_subdirectory(GetEnvironmentStringsW) add_subdirectory(GetEnvironmentVariableA) add_subdirectory(GetEnvironmentVariableW) diff --git a/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/test.c b/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/test.c index ad01ed0dea..fa82620d1b 100644 --- a/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/test.c +++ b/src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/test.c @@ -18,7 +18,8 @@ int __cdecl main(int argc, char *argv[]) { - WCHAR wzComputerName[MAX_COMPUTERNAME_LENGTH+1]; + int HOST_NAME_MAX = 255; + WCHAR wzComputerName[HOST_NAME_MAX+1]; DWORD dwSize = sizeof(wzComputerName)/sizeof(wzComputerName[0]); // Initialize the PAL and return FAILURE if this fails @@ -32,8 +33,8 @@ int __cdecl main(int argc, char *argv[]) Fail("ERROR: GetComputerName failed with %d!\n", GetLastError()); } - // dwSize is the length of wzComputerName without NULL - if (dwSize <= 0 || dwSize > (sizeof(wzComputerName)/sizeof(wzComputerName[0]) - 1)) + // dwSize is the length of wzComputerName without NULL + if (dwSize < 0 || dwSize > (sizeof(wzComputerName)/sizeof(wzComputerName[0]) - 1)) { Fail("ERROR: GetComputerName returned %S with dwSize = %u whereas the passed in buffer size is %d!\n", wzComputerName, dwSize, sizeof(wzComputerName)/sizeof(wzComputerName[0])); diff --git a/src/pal/tests/palsuite/paltestlist.txt b/src/pal/tests/palsuite/paltestlist.txt index f8c4ee7290..44386ac30e 100644 --- a/src/pal/tests/palsuite/paltestlist.txt +++ b/src/pal/tests/palsuite/paltestlist.txt @@ -642,6 +642,7 @@ miscellaneous/FormatMessageW/test3/paltest_formatmessagew_test3 miscellaneous/FreeEnvironmentStringsW/test1/paltest_freeenvironmentstringsw_test1 miscellaneous/FreeEnvironmentStringsW/test2/paltest_freeenvironmentstringsw_test2 miscellaneous/GetCommandLineW/test1/paltest_getcommandlinew_test1 +miscellaneous/GetComputerNameW/test1/paltest_getcomputernamew_test1 miscellaneous/GetEnvironmentStringsW/test1/paltest_getenvironmentstringsw_test1 miscellaneous/GetEnvironmentVariableA/test1/paltest_getenvironmentvariablea_test1 miscellaneous/GetEnvironmentVariableA/test2/paltest_getenvironmentvariablea_test2 |