Fix build breaks and ensure GetComputerNameW is included in mscorlib.
authorLakshmi Priya Sekar <lasekar@microsoft.com>
Sun, 24 Jan 2016 22:50:28 +0000 (14:50 -0800)
committerLakshmi Priya Sekar <lasekar@microsoft.com>
Mon, 25 Jan 2016 06:07:23 +0000 (22:07 -0800)
src/dlls/mscoree/mscorwks_unixexports.src
src/pal/src/misc/identity.cpp
src/pal/tests/palsuite/miscellaneous/CMakeLists.txt
src/pal/tests/palsuite/miscellaneous/GetComputerNameW/test1/test.c
src/pal/tests/palsuite/paltestlist.txt

index fe4f2a4350290fd939f997835b5b39d2c9207819..71203371776b236416c2247158634bbbbcd42857 100644 (file)
@@ -43,6 +43,7 @@ FlushFileBuffers
 FormatMessageW
 FreeEnvironmentStringsW
 GetACP
+GetComputerNameW
 GetConsoleCP
 GetConsoleOutputCP
 GetCurrentDirectoryW
index 6be3c9d8ac6708bc475a0f990f093ae0d4003bd0..498ad49dcd6b5e27d193cd103fdc10bb929eb4d1 100644 (file)
@@ -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) 
index 800e303f14e066206490ee43822429fd91c4f0c9..86f194198b1753f7a2213b1e4ebd9dc3a720e44c 100644 (file)
@@ -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)
index ad01ed0deab280a9704dd9cc9c5787f348726093..fa82620d1b51b5d373836a507ea738a88ec773e1 100644 (file)
@@ -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]));
index f8c4ee729024ff6b75653ea493b8b010214786ec..44386ac30e30c97e710e3ef95590d87ad2ba5a56 100644 (file)
@@ -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