diff options
author | Lakshmi Priya <Priya91@users.noreply.github.com> | 2015-10-20 19:02:33 -0700 |
---|---|---|
committer | Lakshmi Priya <Priya91@users.noreply.github.com> | 2015-10-20 19:02:33 -0700 |
commit | 6b091902c7f2cc2578a8fb34a7ce8115f0f9cb8b (patch) | |
tree | 4e96346e3553794801688a4c83c379d25506dd1e /src | |
parent | 96515c550cf891cc62287cd6f03ed02894f9a5cc (diff) | |
parent | fdbd0a799c370d7fcf3832e04819c5ec9d85b6a7 (diff) | |
download | coreclr-6b091902c7f2cc2578a8fb34a7ce8115f0f9cb8b.tar.gz coreclr-6b091902c7f2cc2578a8fb34a7ce8115f0f9cb8b.tar.bz2 coreclr-6b091902c7f2cc2578a8fb34a7ce8115f0f9cb8b.zip |
Merge pull request #1744 from Priya91/palstring-rest
Use StackString in PAL file apis.
Diffstat (limited to 'src')
-rw-r--r-- | src/pal/src/file/directory.cpp | 38 | ||||
-rw-r--r-- | src/pal/src/file/disk.cpp | 20 | ||||
-rw-r--r-- | src/pal/src/file/file.cpp | 283 | ||||
-rw-r--r-- | src/pal/src/file/find.cpp | 18 | ||||
-rw-r--r-- | src/pal/src/file/path.cpp | 124 | ||||
-rw-r--r-- | src/pal/src/include/pal/map.hpp | 3 | ||||
-rw-r--r-- | src/pal/src/include/pal/stackstring.hpp | 12 | ||||
-rw-r--r-- | src/pal/src/loader/module.cpp | 46 | ||||
-rw-r--r-- | src/pal/src/locale/unicode.cpp | 14 | ||||
-rw-r--r-- | src/pal/src/misc/perftrace.cpp | 47 | ||||
-rw-r--r-- | src/pal/src/shmemory/shmemory.cpp | 994 | ||||
-rw-r--r-- | src/pal/src/synchmgr/synchmanager.cpp | 16 | ||||
-rw-r--r-- | src/pal/src/thread/process.cpp | 26 |
13 files changed, 471 insertions, 1170 deletions
diff --git a/src/pal/src/file/directory.cpp b/src/pal/src/file/directory.cpp index bf4780fea4..3a1747ccca 100644 --- a/src/pal/src/file/directory.cpp +++ b/src/pal/src/file/directory.cpp @@ -24,6 +24,7 @@ Revision History: #include "pal/palinternal.h" #include "pal/dbgmsg.h" #include "pal/file.h" +#include "pal/stackstring.hpp" #if HAVE_ALLOCA_H #include <alloca.h> @@ -195,8 +196,10 @@ RemoveDirectoryA( { DWORD dwLastError = 0; BOOL bRet = FALSE; - char mb_dir[MAX_LONGPATH]; - + PathCharString mb_dirPathString; + size_t length; + char * mb_dir; + PERF_ENTRY(RemoveDirectoryA); ENTRY("RemoveDirectoryA(lpPathName=%p (%s))\n", lpPathName, @@ -208,14 +211,17 @@ RemoveDirectoryA( goto done; } - mb_dir[MAX_LONGPATH - 1] = '\0'; - if (strncpy_s (mb_dir, sizeof(mb_dir), lpPathName, MAX_LONGPATH) != SAFECRT_SUCCESS) + length = strlen(lpPathName); + mb_dir = mb_dirPathString.OpenStringBuffer(length); + if (strncpy_s (mb_dir, sizeof(char) * (length+1), lpPathName, MAX_LONGPATH) != SAFECRT_SUCCESS) { + mb_dirPathString.CloseBuffer(length); WARN("mb_dir is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH); dwLastError = ERROR_FILENAME_EXCED_RANGE; goto done; } + mb_dirPathString.CloseBuffer(length); bRet = RemoveDirectoryHelper (mb_dir, &dwLastError); done: @@ -240,10 +246,12 @@ PALAPI RemoveDirectoryW( IN LPCWSTR lpPathName) { - char mb_dir[MAX_LONGPATH]; + PathCharString mb_dirPathString; int mb_size; DWORD dwLastError = 0; BOOL bRet = FALSE; + size_t length; + char * mb_dir; PERF_ENTRY(RemoveDirectoryW); ENTRY("RemoveDirectoryW(lpPathName=%p (%S))\n", @@ -255,9 +263,13 @@ RemoveDirectoryW( dwLastError = ERROR_PATH_NOT_FOUND; goto done; } - - mb_size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, mb_dir, MAX_LONGPATH, + + length = (PAL_wcslen(lpPathName)+1) * 3; + mb_dir = mb_dirPathString.OpenStringBuffer(length); + mb_size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, mb_dir, length, NULL, NULL ); + mb_dirPathString.CloseBuffer(mb_size); + if( mb_size == 0 ) { dwLastError = GetLastError(); @@ -429,9 +441,11 @@ SetCurrentDirectoryW( { BOOL bRet; DWORD dwLastError = 0; - char dir[MAX_LONGPATH]; + PathCharString dirPathString; int size; - + size_t length; + char * dir; + PERF_ENTRY(SetCurrentDirectoryW); ENTRY("SetCurrentDirectoryW(lpPathName=%p (%S))\n", lpPathName?lpPathName:W16_NULLSTRING, @@ -447,8 +461,12 @@ SetCurrentDirectoryW( goto done; } - size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, dir, MAX_LONGPATH, + length = (PAL_wcslen(lpPathName)+1) * 3; + dir = dirPathString.OpenStringBuffer(length); + size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, dir, length, NULL, NULL ); + dirPathString.CloseBuffer(size); + if( size == 0 ) { dwLastError = GetLastError(); diff --git a/src/pal/src/file/disk.cpp b/src/pal/src/file/disk.cpp index 4bf57da327..2c43fa74bd 100644 --- a/src/pal/src/file/disk.cpp +++ b/src/pal/src/file/disk.cpp @@ -24,6 +24,7 @@ Revision History: #include "pal/palinternal.h" #include "pal/dbgmsg.h" #include "pal/file.h" +#include "pal/stackstring.hpp" #include <sys/param.h> #if !defined(_AIX) @@ -68,7 +69,10 @@ GetDiskFreeSpaceW( pal_statfs fsInfoBuffer; INT statfsRetVal = 0; DWORD dwLastError = NO_ERROR; - CHAR DirNameBuffer[ MAX_LONGPATH ]; + PathCharString dirNameBufferPathString; + size_t length; + char * dirNameBuffer; + int size; PERF_ENTRY(GetDiskFreeSpaceW); ENTRY( "GetDiskFreeSpaceW( lpDirectoryName=%p (%S), lpSectorsPerCluster=%p," @@ -111,11 +115,15 @@ GetDiskFreeSpaceW( if ( lpDirectoryName ) { - if ( WideCharToMultiByte( CP_ACP, 0, lpDirectoryName, -1, - DirNameBuffer,MAX_LONGPATH, 0, 0 ) != 0 ) + length = (PAL_wcslen(lpDirectoryName)+1) * 3; + dirNameBuffer = dirNameBufferPathString.OpenStringBuffer(length); + size = WideCharToMultiByte( CP_ACP, 0, lpDirectoryName, -1, + dirNameBuffer,length, 0, 0 ); + dirNameBufferPathString.CloseBuffer(size); + if ( size != 0 ) { - FILEDosToUnixPathA( DirNameBuffer ); - statfsRetVal = statfs( DirNameBuffer, &fsInfoBuffer ); + FILEDosToUnixPathA( dirNameBuffer ); + statfsRetVal = statfs( dirNameBuffer, &fsInfoBuffer ); } else { @@ -139,7 +147,7 @@ GetDiskFreeSpaceW( { if ( errno == ENOTDIR || errno == ENOENT ) { - FILEGetProperNotFoundError( DirNameBuffer, &dwLastError ); + FILEGetProperNotFoundError( dirNameBuffer, &dwLastError ); goto exit; } dwLastError = FILEGetLastErrorFromErrno(); diff --git a/src/pal/src/file/file.cpp b/src/pal/src/file/file.cpp index c4ac214b5f..3f29c7f519 100644 --- a/src/pal/src/file/file.cpp +++ b/src/pal/src/file/file.cpp @@ -23,6 +23,7 @@ Abstract: #include "pal/file.hpp" #include "shmfilelockmgr.hpp" #include "pal/malloc.hpp" +#include "pal/stackstring.hpp" #include "pal/palinternal.h" #include "pal/dbgmsg.h" @@ -44,6 +45,8 @@ using namespace CorUnix; SET_DEFAULT_DEBUG_CHANNEL(FILE); +int MaxWCharToAcpLengthFactor = 3; + PAL_ERROR InternalSetFilePointerForUnixFd( int iUnixFd, @@ -974,8 +977,10 @@ CreateFileW( { CPalThread *pThread; PAL_ERROR palError = NO_ERROR; - char name[MAX_LONGPATH]; - int size; + PathCharString namePathString; + char * name; + int size; + int length = 0; HANDLE hRet = INVALID_HANDLE_VALUE; PERF_ENTRY(CreateFileW); @@ -988,8 +993,16 @@ CreateFileW( pThread = InternalGetCurrentThread(); - size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, MAX_LONGPATH, + if (lpFileName != NULL) + { + length = (PAL_wcslen(lpFileName)+1) * MaxWCharToAcpLengthFactor; + } + + name = namePathString.OpenStringBuffer(length); + size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, length, NULL, NULL ); + namePathString.CloseBuffer(size); + if( size == 0 ) { DWORD dwLastError = GetLastError(); @@ -1053,10 +1066,12 @@ CopyFileW( IN BOOL bFailIfExists) { CPalThread *pThread; - char source[MAX_LONGPATH]; - char dest[MAX_LONGPATH]; - int src_size,dest_size; - BOOL bRet = FALSE; + PathCharString sourcePathString; + PathCharString destPathString; + char * source; + char * dest; + int src_size, dest_size, length = 0; + BOOL bRet = FALSE; PERF_ENTRY(CopyFileW); ENTRY("CopyFileW(lpExistingFileName=%p (%S), lpNewFileName=%p (%S), bFailIfExists=%d)\n", @@ -1066,8 +1081,16 @@ CopyFileW( lpNewFileName?lpNewFileName:W16_NULLSTRING, bFailIfExists); pThread = InternalGetCurrentThread(); - src_size = WideCharToMultiByte( CP_ACP, 0, lpExistingFileName, -1, source, MAX_LONGPATH, + if (lpExistingFileName != NULL) + { + length = (PAL_wcslen(lpExistingFileName)+1) * MaxWCharToAcpLengthFactor; + } + + source = sourcePathString.OpenStringBuffer(length); + src_size = WideCharToMultiByte( CP_ACP, 0, lpExistingFileName, -1, source, length, NULL, NULL ); + sourcePathString.CloseBuffer(src_size); + if( src_size == 0 ) { DWORD dwLastError = GetLastError(); @@ -1084,8 +1107,17 @@ CopyFileW( goto done; } - dest_size = WideCharToMultiByte( CP_ACP, 0, lpNewFileName, -1, dest, MAX_LONGPATH, + length = 0; + if (lpNewFileName != NULL) + { + length = (PAL_wcslen(lpNewFileName)+1) * MaxWCharToAcpLengthFactor; + } + + dest = destPathString.OpenStringBuffer(length); + dest_size = WideCharToMultiByte( CP_ACP, 0, lpNewFileName, -1, dest, length, NULL, NULL ); + destPathString.CloseBuffer(dest_size); + if( dest_size == 0 ) { DWORD dwLastError = GetLastError(); @@ -1128,7 +1160,9 @@ DeleteFileA( int result; BOOL bRet = FALSE; DWORD dwLastError = 0; - char lpUnixFileName[MAX_LONGPATH]; + char * lpUnixFileName; + int length; + PathCharString lpUnixFileNamePS; LPSTR lpFullUnixFileName = NULL; DWORD cchFullUnixFileName = MAX_LONGPATH+1;// InternalCanonicalizeRealPath requires this to be atleast PATH_MAX @@ -1136,14 +1170,11 @@ DeleteFileA( ENTRY("DeleteFileA(lpFileName=%p (%s))\n", lpFileName?lpFileName:"NULL", lpFileName?lpFileName:"NULL"); pThread = InternalGetCurrentThread(); - if (strlen(lpFileName) >= MAX_LONGPATH) - { - WARN("lpFileName is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH); - pThread->SetLastError(ERROR_FILENAME_EXCED_RANGE); - goto done; - } + length = strlen(lpFileName); - strcpy_s( lpUnixFileName, sizeof(lpUnixFileName), lpFileName); + lpUnixFileName = lpUnixFileNamePS.OpenStringBuffer(length); + strcpy_s( lpUnixFileName, lpUnixFileNamePS.GetSizeOf(), lpFileName); + lpUnixFileNamePS.CloseBuffer(length); FILEDosToUnixPathA( lpUnixFileName ); @@ -1241,7 +1272,9 @@ DeleteFileW( { CPalThread *pThread; int size; - char name[MAX_LONGPATH]; + PathCharString namePS; + char * name; + int length = 0; BOOL bRet = FALSE; PERF_ENTRY(DeleteFileW); @@ -1250,8 +1283,17 @@ DeleteFileW( lpFileName?lpFileName:W16_NULLSTRING); pThread = InternalGetCurrentThread(); - size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, MAX_LONGPATH, + + if (lpFileName != NULL) + { + length = (PAL_wcslen(lpFileName)+1) * MaxWCharToAcpLengthFactor; + } + + name = namePS.OpenStringBuffer(length); + size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, length, NULL, NULL ); + namePS.CloseBuffer(size); + if( size == 0 ) { DWORD dwLastError = GetLastError(); @@ -1354,8 +1396,11 @@ MoveFileExA( { CPalThread *pThread; int result; - char source[MAX_LONGPATH]; - char dest[MAX_LONGPATH]; + int length = 0; + PathCharString sourcePS; + PathCharString destPS; + char * source; + char * dest; BOOL bRet = TRUE; DWORD dwLastError = 0; @@ -1376,26 +1421,20 @@ MoveFileExA( goto done; } - if (strlen(lpExistingFileName) >= MAX_LONGPATH) - { - WARN("lpExistingFileName is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH); - pThread->SetLastError(ERROR_FILENAME_EXCED_RANGE); - goto done; - } + length = strlen(lpExistingFileName); + + source = sourcePS.OpenStringBuffer(length); + strcpy_s( source, sourcePS.GetSizeOf(), lpExistingFileName); + sourcePS.CloseBuffer(length); - strcpy_s( source, sizeof(source), lpExistingFileName); - FILEDosToUnixPathA( source ); - if (strlen(lpNewFileName) >= MAX_LONGPATH) - { - WARN("lpNewFileName is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH); - pThread->SetLastError(ERROR_FILENAME_EXCED_RANGE); - goto done; - } + length = strlen(lpNewFileName); + + dest = destPS.OpenStringBuffer(length); + strcpy_s( dest, destPS.GetSizeOf(), lpNewFileName); + destPS.CloseBuffer(length); - strcpy_s( dest, sizeof(dest), lpNewFileName); - FILEDosToUnixPathA( dest ); if ( !FILEGetFileNameFromSymLink(source)) @@ -1527,8 +1566,11 @@ MoveFileExW( IN DWORD dwFlags) { CPalThread *pThread; - char source[MAX_LONGPATH]; - char dest[MAX_LONGPATH]; + PathCharString sourcePS; + PathCharString destPS; + char * source; + char * dest; + int length = 0; int src_size,dest_size; BOOL bRet = FALSE; @@ -1540,8 +1582,16 @@ MoveFileExW( lpNewFileName?lpNewFileName:W16_NULLSTRING, dwFlags); pThread = InternalGetCurrentThread(); - src_size = WideCharToMultiByte( CP_ACP, 0, lpExistingFileName, -1, source, MAX_LONGPATH, + + if (lpExistingFileName != NULL) + { + length = (PAL_wcslen(lpExistingFileName)+1) * MaxWCharToAcpLengthFactor; + } + + source = sourcePS.OpenStringBuffer(length); + src_size = WideCharToMultiByte( CP_ACP, 0, lpExistingFileName, -1, source, length, NULL, NULL ); + sourcePS.CloseBuffer(src_size); if( src_size == 0 ) { DWORD dwLastError = GetLastError(); @@ -1558,8 +1608,17 @@ MoveFileExW( goto done; } - dest_size = WideCharToMultiByte( CP_ACP, 0, lpNewFileName, -1, dest, MAX_LONGPATH, + length = 0; + if (lpNewFileName != NULL) + { + length = (PAL_wcslen(lpNewFileName)+1) * MaxWCharToAcpLengthFactor; + } + + dest = destPS.OpenStringBuffer(length); + dest_size = WideCharToMultiByte( CP_ACP, 0, lpNewFileName, -1, dest, length, NULL, NULL ); + destPS.CloseBuffer(dest_size); + if( dest_size == 0 ) { DWORD dwLastError = GetLastError(); @@ -1618,7 +1677,9 @@ GetFileAttributesA( struct stat stat_data; DWORD dwAttr = 0; DWORD dwLastError = 0; - CHAR UnixFileName[MAX_LONGPATH + 1]; + CHAR * UnixFileName; + int length = 0; + PathCharString UnixFileNamePS; PERF_ENTRY(GetFileAttributesA); ENTRY("GetFileAttributesA(lpFileName=%p (%s))\n", lpFileName?lpFileName:"NULL", lpFileName?lpFileName:"NULL"); @@ -1630,15 +1691,12 @@ GetFileAttributesA( goto done; } - if (strlen(lpFileName) >= MAX_LONGPATH) - { - WARN("lpFileName is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH); - dwLastError = ERROR_FILENAME_EXCED_RANGE; - goto done; - } + length = strlen(lpFileName); + + UnixFileName = UnixFileNamePS.OpenStringBuffer(length); + strcpy_s( UnixFileName, UnixFileNamePS.GetSizeOf(), lpFileName ); + UnixFileNamePS.CloseBuffer(length); - strcpy_s( UnixFileName, sizeof(UnixFileName), lpFileName ); - FILEDosToUnixPathA( UnixFileName ); if ( stat(UnixFileName, &stat_data) != 0 ) @@ -1701,7 +1759,9 @@ GetFileAttributesW( { CPalThread *pThread; int size; - char filename[MAX_LONGPATH]; + PathCharString filenamePS; + int length = 0; + char * filename; DWORD dwRet = (DWORD) -1; PERF_ENTRY(GetFileAttributesW); @@ -1716,8 +1776,12 @@ GetFileAttributesW( goto done; } - size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, filename, MAX_LONGPATH, + length = (PAL_wcslen(lpFileName)+1) * MaxWCharToAcpLengthFactor; + filename = filenamePS.OpenStringBuffer(length); + size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, filename, length, NULL, NULL ); + filenamePS.CloseBuffer(size); + if( size == 0 ) { DWORD dwLastError = GetLastError(); @@ -1761,7 +1825,9 @@ GetFileAttributesExW( struct stat stat_data; - char name[MAX_LONGPATH]; + char * name; + PathCharString namePS; + int length = 0; int size; PERF_ENTRY(GetFileAttributesExW); @@ -1790,8 +1856,12 @@ GetFileAttributesExW( goto done; } - size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, MAX_LONGPATH, + length = (PAL_wcslen(lpFileName)+1) * MaxWCharToAcpLengthFactor; + name = namePS.OpenStringBuffer(length); + size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, length, NULL, NULL ); + namePS.CloseBuffer(size); + if( size == 0 ) { dwLastError = GetLastError(); @@ -1871,7 +1941,9 @@ SetFileAttributesW( IN DWORD dwFileAttributes) { CPalThread *pThread; - char name[MAX_LONGPATH]; + char * name; + PathCharString namePS; + int length = 0; int size; DWORD dwLastError = 0; @@ -1889,8 +1961,12 @@ SetFileAttributesW( goto done; } - size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, MAX_LONGPATH, + length = (PAL_wcslen(lpFileName)+1) * MaxWCharToAcpLengthFactor; + name = namePS.OpenStringBuffer(length); + size = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, name, length, NULL, NULL ); + namePS.CloseBuffer(size); + if( size == 0 ) { dwLastError = GetLastError(); @@ -3367,8 +3443,11 @@ GetTempFileNameA( OUT LPSTR lpTempFileName) { CPalThread *pThread; - CHAR full_name[ MAX_LONGPATH + 1 ]; - CHAR file_template[ MAX_LONGPATH + 1 ]; + CHAR * full_name; + PathCharString full_namePS; + int length; + CHAR * file_template; + PathCharString file_templatePS; CHAR chLastPathNameChar; HANDLE hTempFile; @@ -3414,27 +3493,33 @@ GetTempFileNameA( goto done; } + length = strlen(lpPathName) + MAX_SEEDSIZE + MAX_PREFIX + 10; + file_template = file_templatePS.OpenStringBuffer(length); *file_template = '\0'; - strcat_s( file_template, sizeof(file_template), lpPathName ); + strcat_s( file_template, file_templatePS.GetSizeOf(), lpPathName ); + file_templatePS.CloseBuffer(length); chLastPathNameChar = file_template[strlen(file_template)-1]; if (chLastPathNameChar != '\\' && chLastPathNameChar != '/') { - strcat_s( file_template, sizeof(file_template), "\\" ); + strcat_s( file_template, file_templatePS.GetSizeOf(), "\\" ); } if ( lpPrefixString ) { - strncat_s( file_template, sizeof(file_template), lpPrefixString, MAX_PREFIX ); + strncat_s( file_template, file_templatePS.GetSizeOf(), lpPrefixString, MAX_PREFIX ); } FILEDosToUnixPathA( file_template ); - strncat_s( file_template, sizeof(file_template), "%.4x.TMP", MAX_SEEDSIZE ); + strncat_s( file_template, file_templatePS.GetSizeOf(), "%.4x.TMP", MAX_SEEDSIZE ); /* Create the file. */ dwError = GetLastError(); pThread->SetLastError( NOERROR ); - sprintf_s( full_name, sizeof(full_name), file_template, (0 == uUnique) ? uUniqueSeed : uUnique); + length = strlen(file_template) + MAX_SEEDSIZE + MAX_PREFIX; + full_name = full_namePS.OpenStringBuffer(length); + sprintf_s( full_name, full_namePS.GetSizeOf(), file_template, (0 == uUnique) ? uUniqueSeed : uUnique); + full_namePS.CloseBuffer(length); hTempFile = CreateFileA( full_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, 0, NULL ); @@ -3453,7 +3538,7 @@ GetTempFileNameA( ENSURE_UNIQUE_NOT_ZERO; pThread->SetLastError( NOERROR ); - sprintf_s( full_name, sizeof(full_name), file_template, uUniqueSeed ); + sprintf_s( full_name, full_namePS.GetSizeOf(), file_template, uUniqueSeed ); hTempFile = CreateFileA( full_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, 0, NULL ); uLoopCounter++; @@ -3543,9 +3628,11 @@ GetTempFileNameW( CPalThread *pThread; INT path_size = 0; INT prefix_size = 0; - CHAR full_name[ MAX_LONGPATH + 1 ]; - CHAR prefix_string[ MAX_LONGPATH + 1 ]; - CHAR tempfile_name[ MAX_PATH_FNAME + 1 ]; + CHAR * full_name; + CHAR * prefix_string; + CHAR * tempfile_name; + PathCharString full_namePS, prefix_stringPS; + INT length = 0; UINT uRet; PERF_ENTRY(GetTempFileNameW); @@ -3563,8 +3650,12 @@ GetTempFileNameW( goto done; } + length = (PAL_wcslen(lpPathName)+1) * MaxWCharToAcpLengthFactor; + full_name = full_namePS.OpenStringBuffer(length); path_size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, full_name, - MAX_LONGPATH, NULL, NULL ); + length, NULL, NULL ); + full_namePS.CloseBuffer(path_size); + if( path_size == 0 ) { DWORD dwLastError = GetLastError(); @@ -3584,10 +3675,14 @@ GetTempFileNameW( if (lpPrefixString != NULL) { + length = (PAL_wcslen(lpPrefixString)+1) * MaxWCharToAcpLengthFactor; + prefix_string = prefix_stringPS.OpenStringBuffer(length); prefix_size = WideCharToMultiByte( CP_ACP, 0, lpPrefixString, -1, prefix_string, MAX_LONGPATH - path_size - MAX_SEEDSIZE, NULL, NULL ); + prefix_stringPS.CloseBuffer(prefix_size); + if( prefix_size == 0 ) { DWORD dwLastError = GetLastError(); @@ -3605,28 +3700,41 @@ GetTempFileNameW( goto done; } } - + + tempfile_name = new char[MAX_LONGPATH]; + if (tempfile_name == NULL) + { + pThread->SetLastError(ERROR_NOT_ENOUGH_MEMORY); + uRet = 0; + goto done; + } + uRet = GetTempFileNameA(full_name, (lpPrefixString == NULL) ? NULL : prefix_string, 0, tempfile_name); - - if ( uRet && !MultiByteToWideChar( CP_ACP, 0, tempfile_name, -1, - lpTempFileName, MAX_PATH_FNAME )) - { - DWORD dwLastError = GetLastError(); - if (dwLastError == ERROR_INSUFFICIENT_BUFFER) - { - WARN("File names larger than MAX_PATH_FNAME (%d)! \n", MAX_PATH_FNAME); - dwLastError = ERROR_FILENAME_EXCED_RANGE; - } - else + if (uRet) + { + path_size = MultiByteToWideChar( CP_ACP, 0, tempfile_name, -1, + lpTempFileName, MAX_LONGPATH ); + + delete [] tempfile_name; + tempfile_name = NULL; + if (!path_size) { - ASSERT("MultiByteToWideChar failure! error is %d", dwLastError); - dwLastError = ERROR_INTERNAL_ERROR; + DWORD dwLastError = GetLastError(); + if (dwLastError == ERROR_INSUFFICIENT_BUFFER) + { + WARN("File names larger than MAX_PATH_FNAME (%d)! \n", MAX_LONGPATH); + dwLastError = ERROR_FILENAME_EXCED_RANGE; + } + else + { + ASSERT("MultiByteToWideChar failure! error is %d", dwLastError); + dwLastError = ERROR_INTERNAL_ERROR; + } + pThread->SetLastError(dwLastError); + uRet = 0; } - pThread->SetLastError(dwLastError); - uRet = 0; - goto done; } done: @@ -4773,7 +4881,7 @@ Return value: BOOL FILEGetFileNameFromSymLink(char *source) { int ret; - char sLinkData[MAX_LONGPATH]; + char * sLinkData = new char[MAX_LONGPATH]; do { @@ -4781,10 +4889,11 @@ BOOL FILEGetFileNameFromSymLink(char *source) if (ret>0) { sLinkData[ret] = '\0'; - strcpy_s(source, sizeof(sLinkData), sLinkData); + strcpy_s(source, sizeof(char)*(MAX_LONGPATH), sLinkData); } } while (ret > 0); + delete [] sLinkData; return (errno == EINVAL); } diff --git a/src/pal/src/file/find.cpp b/src/pal/src/file/find.cpp index 76a88cf144..18c3c7f038 100644 --- a/src/pal/src/file/find.cpp +++ b/src/pal/src/file/find.cpp @@ -24,6 +24,7 @@ Revision History: #include "pal/thread.hpp" #include "pal/malloc.hpp" #include "pal/file.hpp" +#include "pal/stackstring.hpp" #include "pal/palinternal.h" #include "pal/dbgmsg.h" @@ -777,18 +778,29 @@ static int FILEGlobFromSplitPath( CPalThread *pthrCurrent, glob_t *pgGlob ) { int Ret; - char Pattern[MAX_LONGPATH]; - char EscapedPattern[2*MAX_LONGPATH]; + PathCharString PatternPS; + PathCharString EscapedPatternPS; + char * Pattern; + int length = 0; + char * EscapedPattern; TRACE("We shall attempt to glob from components [%s][%s][%s]\n", dir?dir:"NULL", fname?fname:"NULL", ext?ext:"NULL"); - FILEMakePathA( Pattern, MAX_LONGPATH, dir, fname, ext ); + if (dir) length = strlen(dir); + if (fname) length += strlen(fname); + if (ext) length += strlen(ext); + + Pattern = PatternPS.OpenStringBuffer(length); + FILEMakePathA( Pattern, length+1, dir, fname, ext ); + PatternPS.CloseBuffer(length); TRACE("Assembled Pattern = [%s]\n", Pattern); /* special handling is needed to handle the case where filename contains '[' and ']' */ + EscapedPattern = EscapedPatternPS.OpenStringBuffer(length*2); FILEEscapeSquareBrackets( Pattern, EscapedPattern); + EscapedPatternPS.CloseBuffer(strlen(EscapedPattern)); #ifdef GLOB_QUOTE flags |= GLOB_QUOTE; #endif // GLOB_QUOTE diff --git a/src/pal/src/file/path.cpp b/src/pal/src/file/path.cpp index 0ad1e62a08..5d3f35f998 100644 --- a/src/pal/src/file/path.cpp +++ b/src/pal/src/file/path.cpp @@ -26,6 +26,7 @@ Revision History: #include "pal/dbgmsg.h" #include "pal/file.h" #include "pal/malloc.hpp" +#include "pal/stackstring.hpp" #include <errno.h> @@ -42,6 +43,7 @@ SET_DEFAULT_DEBUG_CHANNEL(FILE); // should be placed after the SET_DEFAULT_DEBUG_CHANNEL(FILE) #include <safemath.h> +int MaxWCharToAcpLengthRatio = 3; /*++ Function: GetFullPathNameA @@ -194,7 +196,9 @@ GetFullPathNameW( LPSTR fileNameA; /* bufferA needs to be able to hold a path that's potentially as large as MAX_LONGPATH WCHARs. */ - CHAR bufferA[MAX_LONGPATH * sizeof(WCHAR)]; + CHAR * bufferA; + size_t bufferASize = 0; + PathCharString bufferAPS; LPSTR lpFilePartA; int fileNameLength; int srcSize; @@ -212,6 +216,7 @@ GetFullPathNameW( to ANSI. This may be more than MAX_LONGPATH. We try to handle that case, since it may be less than MAX_LONGPATH WCHARs. */ + fileNameLength = WideCharToMultiByte(CP_ACP, 0, lpFileName, -1, NULL, 0, NULL, NULL); if (fileNameLength == 0) @@ -244,9 +249,13 @@ GetFullPathNameW( goto done; } - length = GetFullPathNameA(fileNameA, sizeof(bufferA), bufferA, &lpFilePartA); + bufferASize = MAX_LONGPATH * MaxWCharToAcpLengthRatio; + bufferA = bufferAPS.OpenStringBuffer(bufferASize); + + length = GetFullPathNameA(fileNameA, bufferASize, bufferA, &lpFilePartA); + bufferAPS.CloseBuffer(length); - if (length == 0 || length > sizeof(bufferA)) + if (length == 0 || length > bufferASize) { /* Last error is set by GetFullPathNameA */ nRet = length; @@ -1087,12 +1096,16 @@ SearchPathA( ) { DWORD nRet = 0; - CHAR FullPath[MAX_LONGPATH]; - CHAR CanonicalFullPath[MAX_LONGPATH]; + CHAR * FullPath; + size_t FullPathLength = 0; + PathCharString FullPathPS; + PathCharString CanonicalFullPathPS; + CHAR * CanonicalFullPath; LPCSTR pPathStart; LPCSTR pPathEnd; size_t PathLength; size_t FileNameLength; + DWORD length; DWORD dw; PERF_ENTRY(SearchPathA); @@ -1136,11 +1149,23 @@ SearchPathA( goto done; } /* Canonicalize the path to deal with back-to-back '/', etc. */ - dw = GetFullPathNameA(lpFileName, MAX_LONGPATH, CanonicalFullPath, NULL); - if (dw == 0 || dw >= MAX_LONGPATH) + length = MAX_LONGPATH; + CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(length); + dw = GetFullPathNameA(lpFileName, length+1, CanonicalFullPath, NULL); + CanonicalFullPathPS.CloseBuffer(dw); + + if (length+1 < dw) + { + CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(dw-1); + dw = GetFullPathNameA(lpFileName, dw, + CanonicalFullPath, NULL); + CanonicalFullPathPS.CloseBuffer(dw); + } + + if (dw == 0) { WARN("couldn't canonicalize path <%s>, error is %#x. failing.\n", - FullPath, GetLastError()); + lpFileName, GetLastError()); SetLastError(ERROR_INVALID_PARAMETER); goto done; } @@ -1194,9 +1219,11 @@ SearchPathA( /* Construct a pathname by concatenating one path from lpPath, '/' and lpFileName */ + FullPathLength = PathLength + FileNameLength; + FullPath = FullPathPS.OpenStringBuffer(FullPathLength+1); memcpy(FullPath, pPathStart, PathLength); FullPath[PathLength] = '/'; - if (strcpy_s(&FullPath[PathLength+1], MAX_LONGPATH-PathLength, lpFileName) != SAFECRT_SUCCESS) + if (strcpy_s(&FullPath[PathLength+1], FullPathLength+1-PathLength, lpFileName) != SAFECRT_SUCCESS) { ERROR("strcpy_s failed!\n"); SetLastError( ERROR_FILENAME_EXCED_RANGE ); @@ -1204,10 +1231,23 @@ SearchPathA( goto done; } + FullPathPS.CloseBuffer(FullPathLength+1); /* Canonicalize the path to deal with back-to-back '/', etc. */ - dw = GetFullPathNameA(FullPath, MAX_LONGPATH, + length = MAX_LONGPATH; + CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(length); + dw = GetFullPathNameA(FullPath, length+1, CanonicalFullPath, NULL); - if (dw == 0 || dw >= MAX_LONGPATH) + CanonicalFullPathPS.CloseBuffer(dw); + + if (length+1 < dw) + { + CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(dw-1); + dw = GetFullPathNameA(FullPath, dw, + CanonicalFullPath, NULL); + CanonicalFullPathPS.CloseBuffer(dw); + } + + if (dw == 0) { /* Call failed - possibly low memory. Skip the path */ WARN("couldn't canonicalize path <%s>, error is %#x. " @@ -1305,14 +1345,21 @@ SearchPathW( ) { DWORD nRet = 0; - WCHAR FullPath[MAX_LONGPATH]; + WCHAR * FullPath; + size_t FullPathLength = 0; + PathWCharString FullPathPS; LPCWSTR pPathStart; LPCWSTR pPathEnd; size_t PathLength; size_t FileNameLength; DWORD dw; - char AnsiPath[MAX_LONGPATH]; - WCHAR CanonicalPath[MAX_LONGPATH]; + DWORD length; + char * AnsiPath; + PathCharString AnsiPathPS; + size_t CanonicalPathLength; + int canonical_size; + WCHAR * CanonicalPath; + PathWCharString CanonicalPathPS; PERF_ENTRY(SearchPathW); ENTRY("SearchPathW(lpPath=%p (%S), lpFileName=%p (%S), lpExtension=%p, " @@ -1347,8 +1394,18 @@ SearchPathW( if('\\' == lpFileName[0] || '/' == lpFileName[0]) { /* Canonicalize the path to deal with back-to-back '/', etc. */ - dw = GetFullPathNameW(lpFileName, MAX_LONGPATH, CanonicalPath, NULL); - if (dw == 0 || dw >= MAX_LONGPATH) + length = MAX_LONGPATH; + CanonicalPath = CanonicalPathPS.OpenStringBuffer(length); + dw = GetFullPathNameW(lpFileName, length+1, CanonicalPath, NULL); + CanonicalPathPS.CloseBuffer(dw); + if (length+1 < dw) + { + CanonicalPath = CanonicalPathPS.OpenStringBuffer(dw-1); + dw = GetFullPathNameW(lpFileName, dw, CanonicalPath, NULL); + CanonicalPathPS.CloseBuffer(dw); + } + + if (dw == 0) { WARN("couldn't canonicalize path <%S>, error is %#x. failing.\n", lpPath, GetLastError()); @@ -1357,8 +1414,12 @@ SearchPathW( } /* see if the file exists */ - WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1, - AnsiPath, MAX_LONGPATH, NULL, NULL); + CanonicalPathLength = (PAL_wcslen(CanonicalPath)+1) * MaxWCharToAcpLengthRatio; + AnsiPath = AnsiPathPS.OpenStringBuffer(CanonicalPathLength); + canonical_size = WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1, + AnsiPath, CanonicalPathLength, NULL, NULL); + AnsiPathPS.CloseBuffer(canonical_size); + if(0 == access(AnsiPath, F_OK)) { /* found it */ @@ -1409,14 +1470,29 @@ SearchPathW( /* Construct a pathname by concatenating one path from lpPath, '/' and lpFileName */ + FullPathLength = PathLength + FileNameLength; + FullPath = FullPathPS.OpenStringBuffer(FullPathLength+1); memcpy(FullPath, pPathStart, PathLength*sizeof(WCHAR)); FullPath[PathLength] = '/'; PAL_wcscpy(&FullPath[PathLength+1], lpFileName); + + FullPathPS.CloseBuffer(FullPathLength+1); /* Canonicalize the path to deal with back-to-back '/', etc. */ - dw = GetFullPathNameW(FullPath, MAX_LONGPATH, + length = MAX_LONGPATH; + CanonicalPath = CanonicalPathPS.OpenStringBuffer(length); + dw = GetFullPathNameW(FullPath, length+1, CanonicalPath, NULL); - if (dw == 0 || dw >= MAX_LONGPATH) + CanonicalPathPS.CloseBuffer(dw); + + if (length+1 < dw) + { + CanonicalPath = CanonicalPathPS.OpenStringBuffer(dw-1); + dw = GetFullPathNameW(FullPath, dw, CanonicalPath, NULL); + CanonicalPathPS.CloseBuffer(dw); + } + + if (dw == 0) { /* Call failed - possibly low memory. Skip the path */ WARN("couldn't canonicalize path <%S>, error is %#x. " @@ -1425,8 +1501,12 @@ SearchPathW( } /* see if the file exists */ - WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1, - AnsiPath, MAX_LONGPATH, NULL, NULL); + CanonicalPathLength = (PAL_wcslen(CanonicalPath)+1) * MaxWCharToAcpLengthRatio; + AnsiPath = AnsiPathPS.OpenStringBuffer(CanonicalPathLength); + canonical_size = WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1, + AnsiPath, CanonicalPathLength, NULL, NULL); + AnsiPathPS.CloseBuffer(canonical_size); + if(0 == access(AnsiPath, F_OK)) { /* found it */ diff --git a/src/pal/src/include/pal/map.hpp b/src/pal/src/include/pal/map.hpp index 22812037c9..b3bfe39dcb 100644 --- a/src/pal/src/include/pal/map.hpp +++ b/src/pal/src/include/pal/map.hpp @@ -23,6 +23,7 @@ Abstract: #define _PAL_MAP_H_ #include "corunix.hpp" +#include <sys/param.h> extern "C" { @@ -144,7 +145,7 @@ namespace CorUnix class CFileMappingImmutableData { public: - CHAR szFileName[MAX_LONGPATH + 1]; + CHAR szFileName[MAXPATHLEN]; UINT MaxSize; // The max size of the file mapping object DWORD flProtect; // Protection desired for the file view BOOL bPALCreatedTempFile; // TRUE if it's a PAL created file diff --git a/src/pal/src/include/pal/stackstring.hpp b/src/pal/src/include/pal/stackstring.hpp index 392c8319f8..3e9a057df2 100644 --- a/src/pal/src/include/pal/stackstring.hpp +++ b/src/pal/src/include/pal/stackstring.hpp @@ -12,7 +12,8 @@ class StackString private: T m_innerBuffer[STACKCOUNT + 1]; T * m_buffer; - SIZE_T m_count; // actual allocated count + SIZE_T m_size; // actual allocated size + SIZE_T m_count; // actual length of string void NullTerminate() { @@ -45,6 +46,7 @@ private: DeleteBuffer(); m_buffer = newBuffer; m_count = count; + m_size = count+1; return; } @@ -59,6 +61,7 @@ private: } else { + m_size = STACKCOUNT+1; m_buffer = m_innerBuffer; m_count = count; } @@ -66,9 +69,14 @@ private: else if (m_innerBuffer == m_buffer) { if (count > STACKCOUNT) + { ReallocateBuffer(count); + } else + { m_count = count; + m_size = STACKCOUNT+1; + } } else { @@ -112,7 +120,7 @@ public: SIZE_T GetSizeOf() const { - return (m_count+1) * sizeof(T); + return m_size * sizeof(T); } CONST T * GetString() const diff --git a/src/pal/src/loader/module.cpp b/src/pal/src/loader/module.cpp index 07bb76530b..dff7de0d1c 100644 --- a/src/pal/src/loader/module.cpp +++ b/src/pal/src/loader/module.cpp @@ -34,6 +34,7 @@ Abstract: #include "pal/misc.h" #include "pal/virtual.h" #include "pal/map.hpp" +#include "pal/stackstring.hpp" #include <sys/param.h> #include <errno.h> @@ -92,14 +93,16 @@ CRITICAL_SECTION module_critsec; MODSTRUCT exe_module; MODSTRUCT *pal_module = NULL; -char g_szCoreCLRPath[MAX_LONGPATH] = { 0 }; +char * g_szCoreCLRPath = NULL; +size_t g_cbszCoreCLRPath = MAX_LONGPATH * sizeof(char); +int MaxWCharToAcpLength = 3; /* static function declarations ***********************************************/ template<class TChar> bool LOADVerifyLibraryPath(const TChar *libraryPath); bool LOADConvertLibraryPathWideStringToMultibyteString( LPCWSTR wideLibraryPath, - CHAR (&multibyteLibraryPath)[MAX_LONGPATH], + LPSTR multibyteLibraryPath, INT *multibyteLibraryPathLengthRef); static BOOL LOADValidateModule(MODSTRUCT *module); @@ -220,8 +223,9 @@ LoadLibraryExW( return NULL; } - CHAR lpstr[MAX_LONGPATH]; + CHAR * lpstr; INT name_length; + PathCharString pathstr; HMODULE hModule = NULL; PERF_ENTRY(LoadLibraryExW); @@ -234,6 +238,7 @@ LoadLibraryExW( goto done; } + lpstr = pathstr.OpenStringBuffer((PAL_wcslen(lpLibFileName)+1) * MaxWCharToAcpLength); if (!LOADConvertLibraryPathWideStringToMultibyteString(lpLibFileName, lpstr, &name_length)) { goto done; @@ -241,6 +246,7 @@ LoadLibraryExW( /* do the Dos/Unix conversion on our own copy of the name */ FILEDosToUnixPathA(lpstr); + pathstr.CloseBuffer(name_length); /* let LOADLoadLibrary call SetLastError in case of failure */ hModule = LOADLoadLibrary(lpstr, TRUE); @@ -264,7 +270,8 @@ PALAPI PAL_LoadLibraryDirect( IN LPCWSTR lpLibFileName) { - CHAR lpstr[MAX_LONGPATH]; + PathCharString pathstr; + CHAR * lpstr = NULL; INT name_length; HMODULE hModule = NULL; @@ -277,6 +284,8 @@ PAL_LoadLibraryDirect( { goto done; } + + lpstr = pathstr.OpenStringBuffer((PAL_wcslen(lpLibFileName)+1) * MaxWCharToAcpLength); if (!LOADConvertLibraryPathWideStringToMultibyteString(lpLibFileName, lpstr, &name_length)) { @@ -285,6 +294,7 @@ PAL_LoadLibraryDirect( /* do the Dos/Unix conversion on our own copy of the name */ FILEDosToUnixPathA(lpstr); + pathstr.CloseBuffer(name_length); /* let LOADLoadLibraryDirect call SetLastError in case of failure */ hModule = LOADLoadLibraryDirect(lpstr, true /* setLastError */); @@ -309,7 +319,8 @@ PAL_RegisterLibraryDirect( IN HMODULE dl_handle, IN LPCWSTR lpLibFileName) { - CHAR lpstr[MAX_LONGPATH]; + PathCharString pathstr; + CHAR * lpstr = NULL; INT name_length; HMODULE hModule = NULL; @@ -323,6 +334,7 @@ PAL_RegisterLibraryDirect( goto done; } + lpstr = pathstr.OpenStringBuffer((PAL_wcslen(lpLibFileName)+1) * MaxWCharToAcpLength); if (!LOADConvertLibraryPathWideStringToMultibyteString(lpLibFileName, lpstr, &name_length)) { goto done; @@ -330,6 +342,7 @@ PAL_RegisterLibraryDirect( /* do the Dos/Unix conversion on our own copy of the name */ FILEDosToUnixPathA(lpstr); + pathstr.CloseBuffer(name_length); /* let LOADRegisterLibraryDirect call SetLastError in case of failure */ LockModuleList(); @@ -1237,14 +1250,16 @@ bool LOADVerifyLibraryPath(const TChar *libraryPath) // Converts the wide char library path string into a multibyte-char string. On error, calls SetLastError() and returns false. bool LOADConvertLibraryPathWideStringToMultibyteString( LPCWSTR wideLibraryPath, - CHAR(&multibyteLibraryPath)[MAX_LONGPATH], + LPSTR multibyteLibraryPath, INT *multibyteLibraryPathLengthRef) { - _ASSERTE(wideLibraryPath != nullptr); _ASSERTE(multibyteLibraryPathLengthRef != nullptr); + _ASSERTE(wideLibraryPath != nullptr); + size_t length = (PAL_wcslen(wideLibraryPath)+1) * MaxWCharToAcpLength; *multibyteLibraryPathLengthRef = WideCharToMultiByte(CP_ACP, 0, wideLibraryPath, -1, multibyteLibraryPath, - MAX_LONGPATH, nullptr, nullptr); + length, nullptr, nullptr); + if (*multibyteLibraryPathLengthRef == 0) { DWORD dwLastError = GetLastError(); @@ -1596,7 +1611,8 @@ Return value : --*/ static HMODULE LOADLoadLibrary(LPCSTR shortAsciiName, BOOL fDynamic) { - CHAR fullLibraryName[MAX_LONGPATH]; + CHAR * fullLibraryName; + PathCharString fullLibraryNamePS; HMODULE module = NULL; HMODULE dl_handle = NULL; @@ -1642,8 +1658,11 @@ static HMODULE LOADLoadLibrary(LPCSTR shortAsciiName, BOOL fDynamic) continue; _ASSERTE(dl_handle == nullptr); - if (snprintf(fullLibraryName, MAX_LONGPATH, formatStrings[i], PAL_SHLIB_PREFIX, shortAsciiName, PAL_SHLIB_SUFFIX) < MAX_LONGPATH) + fullLibraryName = fullLibraryNamePS.OpenStringBuffer(strlen(PAL_SHLIB_PREFIX)+strlen(shortAsciiName)+strlen(PAL_SHLIB_SUFFIX)); + int size = snprintf(fullLibraryName, fullLibraryNamePS.GetSizeOf(), formatStrings[i], PAL_SHLIB_PREFIX, shortAsciiName, PAL_SHLIB_SUFFIX); + if (size < fullLibraryNamePS.GetSizeOf()) { + fullLibraryNamePS.CloseBuffer(size); dl_handle = LOADLoadLibraryDirect(fullLibraryName, false /* setLastError */); if (dl_handle != nullptr) { @@ -1910,7 +1929,12 @@ MODSTRUCT *LOADGetPalLibrary() } // Stash a copy of the CoreCLR installation path in a global variable. // Make sure it's terminated with a slash. - if (strcpy_s(g_szCoreCLRPath, sizeof(g_szCoreCLRPath), info.dli_fname) != SAFECRT_SUCCESS) + if (g_szCoreCLRPath == NULL) + { + g_szCoreCLRPath = new char[g_cbszCoreCLRPath/sizeof(char)]; + } + + if (strcpy_s(g_szCoreCLRPath, g_cbszCoreCLRPath, info.dli_fname) != SAFECRT_SUCCESS) { ERROR("LOADGetPalLibrary: strcpy_s failed!"); goto exit; diff --git a/src/pal/src/locale/unicode.cpp b/src/pal/src/locale/unicode.cpp index 04d4ec96f8..898a4575e4 100644 --- a/src/pal/src/locale/unicode.cpp +++ b/src/pal/src/locale/unicode.cpp @@ -30,6 +30,7 @@ Revision History: #include "pal/utf8.h" #include "pal/locale.h" #include "pal/cruntime.h" +#include "pal/stackstring.hpp" #if !(HAVE_PTHREAD_RWLOCK_T || HAVE_COREFOUNDATION) #error Either pthread rwlocks or Core Foundation are required for Unicode support @@ -953,7 +954,7 @@ EXIT: return retval; } -extern char g_szCoreCLRPath[MAX_LONGPATH]; +extern char * g_szCoreCLRPath; /*++ Function : @@ -967,10 +968,13 @@ PALAPI PAL_BindResources(IN LPCSTR lpDomain) { #ifndef __APPLE__ - char coreCLRDirectoryPath[MAX_LONGPATH]; - - INDEBUG(DWORD size = ) - FILEGetDirectoryFromFullPathA(g_szCoreCLRPath, MAX_LONGPATH, coreCLRDirectoryPath); + _ASSERTE(g_szCoreCLRPath != NULL); + char * coreCLRDirectoryPath; + PathCharString coreCLRDirectoryPathPS; + int len = strlen(g_szCoreCLRPath); + coreCLRDirectoryPath = coreCLRDirectoryPathPS.OpenStringBuffer(len); + DWORD size = FILEGetDirectoryFromFullPathA(g_szCoreCLRPath, len, coreCLRDirectoryPath); + coreCLRDirectoryPathPS.CloseBuffer(size); _ASSERTE(size <= MAX_LONGPATH); LPCSTR boundPath = bindtextdomain(lpDomain, coreCLRDirectoryPath); diff --git a/src/pal/src/misc/perftrace.cpp b/src/pal/src/misc/perftrace.cpp index 68cbb1f669..dc8198aea6 100644 --- a/src/pal/src/misc/perftrace.cpp +++ b/src/pal/src/misc/perftrace.cpp @@ -132,7 +132,7 @@ static double PERFComputeStandardDeviation(pal_perf_api_info *api); static void PERFPrintProgramHeaderInfo(PERF_FILE * hFile, BOOL completedExecution); static BOOL PERFInitProgramInfo(LPWSTR command_line, LPWSTR exe_path); static BOOL PERFReadSetting( ); -static void PERFLogFileName(char *destFileName, const char *fileName, const char *suffix, int max_length); +static void PERFLogFileName(PathCharString * destFileString, const char *fileName, const char *suffix, int max_length); static void PERFlushAllLogs(); static int PERFWriteCounters(pal_perf_api_info * table); static BOOL PERFFlushLog(pal_perf_thread_info * local_buffer, BOOL output_header); @@ -660,9 +660,10 @@ PERFlushAllLogs( ) static void -PERFLogFileName(char *destFileName, const char *fileName, const char *suffix, int max_length) +PERFLogFileName(PathCharString * destFileString, const char *fileName, const char *suffix, int max_length) { const char *dir_path; + char * destFileName = new char[max_length]; dir_path = (profile_log_path == NULL) ? "." : profile_log_path; if (fileName != NULL) @@ -674,20 +675,24 @@ PERFLogFileName(char *destFileName, const char *fileName, const char *suffix, in snprintf(destFileName, max_length, "%s%s%d_%d%s", dir_path, PATH_SEPARATOR, program_info.process_id, THREADSilentGetCurrentThreadId(), suffix); } - + + destFileString.Set(destFileName); + delete [] destFileName; + destFileName = NULL; } static int PERFWriteCounters( pal_perf_api_info * table ) { - char fileName[MAX_LONGPATH]; + PathCharString fileName; pal_perf_api_info * off; PERF_FILE * hFile; int i; off = table; - PERFLogFileName(fileName, profile_summary_log_name, "_perf_summary.log", MAX_LONGPATH); + + PERFLogFileName(&fileName, profile_summary_log_name, "_perf_summary.log", MAX_LONGPATH); hFile = PERF_FILEFN(fopen)(fileName, "a+"); if(hFile != NULL) { @@ -727,7 +732,7 @@ PERFWriteCounters( pal_perf_api_info * table ) if (pal_perf_histogram_size > 0) { off = table; - PERFLogFileName(fileName, profile_summary_log_name, "_perf_summary.hist", MAX_LONGPATH); + PERFLogFileName(&fileName, profile_summary_log_name, "_perf_summary.hist", MAX_LONGPATH); hFile = PERF_FILEFN(fopen)(fileName, "a+"); if (hFile != NULL) @@ -779,7 +784,8 @@ PERFReadSetting( ) char * ptr; char function_name[PAL_PERF_MAX_FUNCTION_NAME]; //no function can be longer than 127 bytes. - char file_name_buf[MAX_LONGPATH]; + char * file_name_buf; + PathCharString file_name_bufPS; char * input_file_name; char * summary_flag_env; char * nested_tracing_env; @@ -896,15 +902,19 @@ PERFReadSetting( ) { if( PERFIsValidFile(perf_default_path,traced_apis_filename)) { - if ((strcpy_s(file_name_buf, sizeof(file_name_buf), perf_default_path) != SAFECRT_SUCCESS) || - (strcat_s(file_name_buf, sizeof(file_name_buf), PATH_SEPARATOR) != SAFECRT_SUCCESS) || - (strcat_s(file_name_buf, sizeof(file_name_buf), traced_apis_filename) != SAFECRT_SUCCESS)) + int length = strlen(perf_default_path) + strlen(PATH_SEPARATOR) + strlen(traced_apis_filename); + file_name_buf = file_name_bufPS.OpenStringBuffer(length); + if ((strcpy_s(file_name_buf, file_name_bufPS.GetSizeOf(), perf_default_path) != SAFECRT_SUCCESS) || + (strcat_s(file_name_buf, file_name_bufPS.GetSizeOf(), PATH_SEPARATOR) != SAFECRT_SUCCESS) || + (strcat_s(file_name_buf, file_name_bufPS.GetSizeOf(), traced_apis_filename) != SAFECRT_SUCCESS)) { + file_name_bufPS.CloseBuffer(0); ret = FALSE; input_file_name = NULL; } else { + file_name_bufPS.CloseBuffer(length); input_file_name = file_name_buf; } } @@ -1068,14 +1078,14 @@ BOOL PERFFlushLog(pal_perf_thread_info * local_info, BOOL output_header) { BOOL ret = FALSE; - char fileName[MAX_LONGPATH]; + PathCharString fileName; int nWrittenBytes = 0; PERF_FILE * hFile; if (summary_only) return TRUE; - PERFLogFileName(fileName, profile_time_log_name, "_perf_time.log", MAX_LONGPATH); + PERFLogFileName(&fileName, profile_time_log_name, "_perf_time.log", MAX_LONGPATH); hFile = PERF_FILEFN(fopen)(fileName, "a+"); @@ -1098,6 +1108,10 @@ PERFFlushLog(pal_perf_thread_info * local_info, BOOL output_header) PERF_FILEFN(fclose)(hFile); ret = TRUE; } + + delete [] fileName; + fileName = NULL; + return ret; } @@ -1422,20 +1436,25 @@ char * PERFIsValidFile( const char * path, const char * file) { FILE * hFile; - char temp[MAX_LONGPATH]; + char * temp; + PathCharString tempPS; if(file==NULL || strlen(file)==0) return NULL; if ( strcmp(path, "") ) - { + { + int length = strlen(path) + strlen(PATH_SEPARATOR) + strlen(file); + temp = tempPS.OpenStringBuffer(length); if ((strcpy_s(temp, sizeof(temp), path) != SAFECRT_SUCCESS) || (strcat_s(temp, sizeof(temp), PATH_SEPARATOR) != SAFECRT_SUCCESS) || (strcat_s(temp, sizeof(temp), file) != SAFECRT_SUCCESS)) { + tempPS.CloseBuffer(0); return NULL; } + tempPS.CloseBuffer(length); hFile = fopen(temp, "r"); } else diff --git a/src/pal/src/shmemory/shmemory.cpp b/src/pal/src/shmemory/shmemory.cpp index 2546635162..509ce796d1 100644 --- a/src/pal/src/shmemory/shmemory.cpp +++ b/src/pal/src/shmemory/shmemory.cpp @@ -277,9 +277,6 @@ segment, each pool is composed of a single contiguous block of memory) */ typedef struct { -#ifndef CORECLR - char next_segment[SEGMENT_NAME_SUFFIX_LENGTH+1]; /* name of next segment */ -#endif // !CORECLR Volatile<SHMPTR> first_pool_blocks[SPS_LAST]; Volatile<SHMPTR> last_pool_blocks[SPS_LAST]; } SHM_SEGMENT_HEADER; @@ -367,65 +364,24 @@ static Volatile<LONG> lock_count; SHMGet/SetInfo will verify that the calling thread holds the lock */ static Volatile<HANDLE> locking_thread; -#ifndef CORECLR -/* suffix template for mkstemp */ -static char segment_name_template[MAX_LONGPATH]; -static char lockfile_name[MAX_LONGPATH]; -#endif // !defined(CORECLR) - /* Constants ******************************************************************/ -#ifndef CORECLR - -/* file name for first shared memory segment */ -static const char first_segment_suffix[] = "segment_1"; - -/* prefix of file name for subsequent shared memory segments */ -static const char segment_name_prefix[] = ".rotor_pal_shm"; - -/* name of lock file (for init/cleanup) */ -static const char lockfile_shortname[] = ".rotor_pal_shmlockfile"; - -#endif // !CORECLR - /* size of a single segment : 256KB */ static const int segment_size = 0x40000; -#if !defined(CORECLR) && defined(_DEBUG) -/* environment variable, set to a non 0 value if we need to output waste - information to the file shm_waste_log (during process termination) */ -static const char* PAL_SAVE_WASTE = "PAL_SAVE_WASTE"; -#endif - /* Static function prototypes *************************************************/ static SHMPTR SHMInitPool(SHMPTR first, int block_size, int pool_size, SHM_POOL_INFO *pool); static SHMPTR SHMLinkPool(SHMPTR first, int block_size, int num_blocks); -#ifndef CORECLR -static LPVOID SHMMapSegment(char *segment_name); -#endif // !CORECLR static BOOL SHMMapUnknownSegments(void); static BOOL SHMAddSegment(void); -#ifndef CORECLR -static BOOL SHMInitSegmentFileSize(int fd); -static int SHMGetProcessList(int fd, pid_t **process_list, BOOL strip_me); -#endif // !CORECLR - -#if !defined(CORECLR) && defined(_DEBUG) -static void init_waste(void); -static void log_waste(enum SHM_POOL_SIZES size, int waste); -static void save_waste(void); - -#else #define init_waste() #define log_waste(x,y) #define save_waste() -#endif - /* Public function implementations ********************************************/ /*++ @@ -437,137 +393,10 @@ memory if no other process has done it. --*/ BOOL SHMInitialize(void) { -#ifndef CORECLR - pid_t *pal_processes; - pid_t this_process; - int n_pal_processes = 0; - int fd_lock; - int fd_map; - int i; - int j; - CHAR config_dir[MAX_LONGPATH]; - CHAR first_segment_name[MAX_LONGPATH]; - ssize_t sBytes; -#endif // !CORECLR - InternalInitializeCriticalSection(&shm_critsec); init_waste(); -#ifndef CORECLR - if ( PALGetPalConfigDir( config_dir, MAX_LONGPATH ) ) - { - if ( ( strlen( config_dir ) + strlen( segment_name_prefix ) + - /* + 3 for the / _ and \0 */ - strlen( first_segment_suffix ) + 3 ) < MAX_LONGPATH && - - ( strlen( config_dir ) + strlen( segment_name_prefix ) + - SEGMENT_NAME_SUFFIX_LENGTH + 3 ) < MAX_LONGPATH ) - { - /* build first segment's file name */ - sprintf( first_segment_name,"%s/%s_%s", config_dir, - segment_name_prefix, first_segment_suffix ); - - /* Initialize mkstemp() template */ - j = sprintf(segment_name_template, "%s/%s_", - config_dir, segment_name_prefix); - - for ( i = 0; i < SEGMENT_NAME_SUFFIX_LENGTH ; i++ ) - { - segment_name_template[i+j] = 'X'; - } - segment_name_template[i+j] = '\0'; - } - else - { - ASSERT( "Configuration directory length + segment name length " - "is greater then MAX_LONGPATH.\n" ); - return FALSE; - } - } - else - { - ASSERT( "Unable to determine the PAL config directory.\n" ); - return FALSE; - } - - /* Once we have access to shared memory, we can use our spinlock for - synchronization. But we also have to be synchronized while we *gain* - access, to prevent 2 processes from trying to initialize the shared - memory system at the same time. We use a separate lockfile for this - purpose; this lockfile will also be used to keep track of which - processes are using shared memory */ - - /* build the lockfile path name */ - sprintf(lockfile_name, "%s/%s", config_dir, lockfile_shortname); - -#ifdef O_EXLOCK - fd_lock = PAL__open(lockfile_name, O_RDWR|O_CREAT|O_EXLOCK, 0600); -#else // O_EXLOCK - fd_lock = PAL__open(lockfile_name, O_RDWR|O_CREAT, 0600); -#endif // O_EXLOCK - if(fd_lock == -1) - { - int retry_count = 0; - - while( fd_lock == -1 && ENOENT == errno && 10 > retry_count) - { - /* directory didn't exist! this means a shutting down PAL - deleted it between our call to INIT_InitPalConfigDir and - here. Try to re-create it a few times, but give up if it - doesn't seem to be working : there's probably something - else wrong */ - WARN("PAL temp dir has disappeared; trying to recreate\n"); - if(!INIT_InitPalConfigDir()) - { - ERROR("couldn't recreate PAL temp dir!\n"); - return FALSE; - } -#ifdef O_EXLOCK - fd_lock = PAL__open(lockfile_name,O_RDWR|O_CREAT|O_EXLOCK, 0600); -#else // O_EXLOCK - fd_lock = PAL__open(lockfile_name,O_RDWR|O_CREAT, 0600); -#endif // O_EXLOCK - retry_count++; - } - if(-1 == fd_lock) - { - ERROR("PAL__open() failed; error is %d (%s)\n", errno, strerror(errno)); - return FALSE; - } - } -#ifndef O_EXLOCK - if (lockf(fd_lock, F_LOCK, 0) == -1) - { - ERROR("lockf() failed; error is %d (%s)\n", errno, strerror(errno)); - close(fd_lock); - return FALSE; - } -#endif // O_EXLOCK - - TRACE("SHM lock file acquired\n"); - - /* got the lock; now check if any other processes are already using shared - memory, or if we must initialize it. The first DWORD of the lockfile - contains the number of registered PAL processes */ - n_pal_processes = SHMGetProcessList(fd_lock, &pal_processes, FALSE); - if( -1 == n_pal_processes ) - { - ERROR("Unable to read process list from lock file!\n"); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - return FALSE; - } - - /* If there are no registered PAL-aware processes, we can initialize - (or re-initialize) the shared memory system */ - if(n_pal_processes == 0) - { -#endif // !CORECLR int size; SHM_FIRST_HEADER *header; SHMPTR pool_start; @@ -576,59 +405,12 @@ BOOL SHMInitialize(void) TRACE("Now initializing global shared memory system\n"); -#ifndef CORECLR - /* open the file, create if necessary (should be necessary)*/ - fd_map = PAL__open(first_segment_name,O_RDWR|O_CREAT,0600); - if(fd_map == -1) - { - ERROR("PAL__open() failed; error is %d (%s)\n", errno, strerror(errno)); - PAL_free(pal_processes); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - return FALSE; - } - - /* Grow file to segment size (256KB) */ - if(!SHMInitSegmentFileSize(fd_map)) - { - ERROR("SHMInitSegmentFileSize() failed; error is %d (%s)\n", - errno, strerror(errno)); - PAL_free(pal_processes); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - close(fd_map); - return FALSE; - } - - shm_segment_bases[0] = mmap(NULL, segment_size,PROT_READ|PROT_WRITE, - MAPFLAGS, fd_map, 0); - - close(fd_map); -#else // !CORECLR // Not really shared in CoreCLR; we don't try to talk to other CoreCLRs. shm_segment_bases[0] = mmap(NULL, segment_size,PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0); -#endif // !CORECLR if(shm_segment_bases[0] == MAP_FAILED) { ERROR("mmap() failed; error is %d (%s)\n", errno, strerror(errno)); -#ifndef CORECLR - PAL_free(pal_processes); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); -#endif // !CORECLR return FALSE; } TRACE("Mapped first SHM segment at %p\n",shm_segment_bases[0].Load()); @@ -650,10 +432,6 @@ BOOL SHMInitialize(void) _ASSERTE(0 == ((DWORD_PTR)&header->spinlock % (DWORD_PTR)sizeof(void *))); #endif // TRACK_SHMLOCK_OWNERSHIP -#ifndef CORECLR - header->header.next_segment[0] = '\0'; /* no next segment */ -#endif // !CORECLR - #ifdef TRACK_SHMLOCK_OWNERSHIP header->pidtidCurrentOwner.pid = 0; header->pidtidCurrentOwner.tid = 0; @@ -681,15 +459,6 @@ BOOL SHMInitialize(void) if(pool_end ==0) { ERROR("SHMInitPool failed.\n"); -#ifndef CORECLR - PAL_free(pal_processes); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); -#endif // !CORECLR munmap(shm_segment_bases[0],segment_size); return FALSE; } @@ -702,127 +471,6 @@ BOOL SHMInitialize(void) } TRACE("Global shared memory initialization complete.\n"); -#ifndef CORECLR - } - else - { - struct stat sb; - - TRACE("Shared memory already initialized : mapping first segment\n") - - fd_map = PAL__open(first_segment_name, O_RDWR); - if(fd_map == -1) - { - ERROR("PAL__open() failed; error is %d (%s)\n", errno, strerror(errno)); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - PAL_free(pal_processes); - return FALSE; - } - - /* find out the segment's size (currently always 256KB, but this may - change and even become variable) */ - if( -1 == fstat(fd_map,&sb) ) - { - ERROR("fstat() failed! error is %d (%s)\n", errno, strerror(errno)); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - close(fd_map); - PAL_free(pal_processes); - return FALSE; - } - - shm_segment_bases[0] = mmap(NULL, sb.st_size,PROT_READ|PROT_WRITE, - MAPFLAGS, fd_map, 0); - close(fd_map); - - if(shm_segment_bases[0] == MAP_FAILED) - { - ERROR("mmap() failed; error is %d (%s)\n", errno, strerror(errno)); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - PAL_free(pal_processes); - return FALSE; - } - TRACE("Successfully accessed first shared memory segment\n"); - } - - /* Re-write lockfile with updated process list */ - - /* empty the file */ - ftruncate(fd_lock,0); - lseek(fd_lock, 0, SEEK_SET); - - n_pal_processes++; - sBytes = write(fd_lock, &n_pal_processes, sizeof(n_pal_processes)); - if(sBytes == -1) - { - ERROR("write() failed; error is %d (%s)\n", errno, strerror(errno)); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - PAL_free(pal_processes); - return FALSE; - } - /* put back all processes that are still alive */ - if(n_pal_processes>1) - { - sBytes = write(fd_lock, pal_processes, (n_pal_processes-1)*sizeof(pid_t)); - if(sBytes == -1) - { - ERROR("write() failed; error is %d (%s)\n", errno, strerror(errno)); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - PAL_free(pal_processes); - return FALSE; - } - } - PAL_free(pal_processes); - - /* add this process to the list */ - this_process = gPID; - sBytes = write(fd_lock, &this_process, sizeof(pid_t)); - if(sBytes == -1) - { - ERROR("write() failed; error is %d (%s)\n", errno, strerror(errno)); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - return FALSE; - } - - /* We're done with the lock file : release it. */ -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - - TRACE("Lock file released; ready to map all shared memory segments\n"); -#endif // !CORECLR shm_numsegments = 1; lock_count = 0; @@ -853,12 +501,6 @@ void SHMCleanup(void) { SHM_FIRST_HEADER *header; pid_t my_pid; -#ifndef CORECLR - int fd_lock; - int n_pal_processes; - pid_t *pal_processes; - ssize_t sBytes; -#endif // !CORECLR TRACE("Starting shared memory cleanup\n"); @@ -878,70 +520,6 @@ void SHMCleanup(void) /* Now for the interprocess stuff. */ DeleteCriticalSection(&shm_critsec); -#ifndef CORECLR - TRACE("Segment unmapping complete; now unregistering this process\n"); - - /* Unregister this process by removing its PID from the lock file. By - locking the lock file here, we ensure that any ongoing SHMInitialize call - will complete before we do anything here, and no subsequent call to - SHMInitialize can proceed until we're done. */ -#ifdef O_EXLOCK - fd_lock = PAL__open(lockfile_name,O_RDWR | O_EXLOCK); -#else // O_EXLOCK - fd_lock = PAL__open(lockfile_name,O_RDWR); -#endif // O_EXLOCK - if(fd_lock == -1) - { - ERROR("PAL__open() failed; error is %d (%s)\n", errno, strerror(errno)); - return; - } -#ifndef O_EXLOCK - if (lockf(fd_lock, F_LOCK, 0) == -1) - { - ERROR("lockf() failed; error is %d (%s)\n", errno, strerror(errno)); - close(fd_lock); - return; - } -#endif // O_EXLOCK - - TRACE("Lockfile acquired\n"); - - /* got the lock; now remove this proces from the list, as well as any - dead process that didn't clean up after itself */ - n_pal_processes = SHMGetProcessList(fd_lock, &pal_processes, TRUE); - if( -1 == n_pal_processes ) - { - ERROR("Unable to read process list from lock file!\n"); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - return; - } - - /* re-write lockfile with updated process list */ - lseek(fd_lock, 0, SEEK_SET); - ftruncate(fd_lock, 0); - - sBytes = write(fd_lock, &n_pal_processes, sizeof(n_pal_processes)); - if(sBytes == -1) - { - ERROR("write() failed; error is %d (%s)\n", errno, strerror(errno)); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - return; - } - - _ASSERT_MSG(0 < n_pal_processes || 0 == header->spinlock, - "SHMCleanup called while process %u still owns the lock [current process=%u\n", - header->spinlock.Load(), getpid()); -#endif // !CORECLR /* Unmap memory segments */ while(shm_numsegments) @@ -955,111 +533,6 @@ void SHMCleanup(void) } } -#ifndef CORECLR - if(n_pal_processes>0) - { - sBytes = write(fd_lock, pal_processes, n_pal_processes*sizeof(pid_t)); - if(sBytes == -1) - { - ERROR("write() failed; error is %d (%s)\n", errno, strerror(errno)); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - return; - } - } - else /* Clean up everything. */ - { - CHAR PalDir[ MAX_LONGPATH + 1 ]; - CHAR FileName[ MAX_LONGPATH + 1 ]; - UINT nEndOfPathAndPrefix = 0; - SHM_SEGMENT_HEADER segment_header; - LPCSTR suffix; - int fd_segment; - - /* Build start of filename. */ - if ( !PALGetPalConfigDir( PalDir, MAX_LONGPATH ) ) - { - ASSERT( "Unable to determine the PAL config directory.\n" ); -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); - return; - } - sprintf( FileName, "%s/%s_", PalDir, segment_name_prefix ); - nEndOfPathAndPrefix = strlen( FileName ); - - /* Unlink all segment files */ - /* Note: we can't rely on all the mapped segment, since it's - possible that another process created another segment that - the current process is not aware. So the solution is to open - the segment files and look at the next one in a loop */ - suffix = first_segment_suffix; - - while ( strlen(suffix) > 0 ) - { - if (strcat_s( FileName, sizeof(FileName), suffix) != SAFECRT_SUCCESS) - { - ERROR("strcat_s failed!"); - break; - } - - fd_segment = PAL__open( FileName, O_RDONLY ); - if( fd_segment == -1 ) - { - WARN("Unable to PAL__open shared memory segment file: %s " - "errno is %d (%s)\n", - FileName, errno, strerror( errno ) ); - break; - } - - if ( read(fd_segment, &segment_header, sizeof(SHM_SEGMENT_HEADER)) != - sizeof(SHM_SEGMENT_HEADER) ) - { - WARN("Unable to read shared memory segment file: %s " - "errno is %d (%s)\n", - FileName, errno, strerror( errno )); - close(fd_segment); - break; - } - - close(fd_segment); - if (unlink(FileName) == -1) - { - WARN("Unable to unlink the shared memory segment file: %s " - "errno is %d (%s)\n", - FileName, errno, strerror( errno )); - } - suffix = segment_header.next_segment; - FileName[ nEndOfPathAndPrefix ] = '\0'; - } - - if ( -1 == unlink(lockfile_name) ) - { - WARN( "Unable to unlink the file! Reason=(%d)%s\n", - errno, strerror( errno ) ); - } - - /* try to remove the PAL's temp directory. this will fail if there are - still files in them; don't insist if that happens */ - INIT_RemovePalConfigDir(); - } - free(pal_processes); - -#ifdef O_EXLOCK - flock(fd_lock, LOCK_UN); -#else // O_EXLOCK - lockf(fd_lock, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd_lock); -#endif // !CORECLR - save_waste(); TRACE("SHMCleanup complete!\n"); } @@ -1824,68 +1297,6 @@ static SHMPTR SHMLinkPool(SHMPTR first, int block_size, int num_blocks) return next_shmptr; } -#ifndef CORECLR -/*++ -SHMMapSegment - -Map the specified SHM segment file into the current process - -Parameters : - char *segment_name : suffix of the segment's file name, as determined by - mkstemp() - -Return value : - Address where the file was mapped ---*/ -static LPVOID SHMMapSegment(char *segment_name) -{ - char segment_path[MAX_LONGPATH]; - int segment_fd; - LPVOID *segment; - struct stat sb; - - /* Construct the file's full path */ - if ( !PALGetPalConfigDir( segment_path, MAX_LONGPATH ) ) - { - ASSERT( "Unable to determine the PAL config directory.\n" ); - return NULL; - } - sprintf_s(segment_path+strlen(segment_path), sizeof(segment_path)-strlen(segment_path), "/%s_%s", - segment_name_prefix, segment_name); - - TRACE("Mapping SHM file %s into process...\n", segment_path); - segment_fd = PAL__open(segment_path,O_RDWR); - if(-1 == segment_fd) - { - ERROR("PAL__open failed! error is %d (%s)\n", errno, strerror(errno)); - return NULL; - } - - /* stat the file to determine its size */ - if( -1 == fstat(segment_fd, &sb) ) - { - ERROR("fstat() failed! error is %d (%s)\n", errno, strerror(errno)); - close(segment_fd); - return NULL; - } - - /* mmap() the file; use MAP_NOSYNC to avoid unnecessary file I/O */ - segment = static_cast<LPVOID *>( - mmap(NULL, sb.st_size,PROT_READ|PROT_WRITE, MAPFLAGS, segment_fd, 0)); - close(segment_fd); - if(segment == MAP_FAILED) - { - ERROR("mmap() failed; error is %d (%s)\n", errno, strerror(errno)); - return NULL; - } - - TRACE("SHM file %s successfully mapped at address %p\n", - segment_name, segment); - - return segment; -} -#endif // !CORECLR - /*++ SHMMapUnknownSegments @@ -1898,54 +1309,7 @@ Return value : --*/ static BOOL SHMMapUnknownSegments(void) { -#ifndef CORECLR - SHM_SEGMENT_HEADER *header; - int num_new = 0; - BOOL retval = FALSE; - - TRACE("Mapping unknown segments into this process...\n"); - - SHMLock(); - - /* Get header of last known segment */ - header = (SHM_SEGMENT_HEADER *) shm_segment_bases[shm_numsegments-1].Load(); - - /* header->next_segment is the suffix of the next segment's file name - (from mkstemp). We use it to map the next segment, then check it to get - the name of the next one, etc. */ - while('\0' != header->next_segment[0]) - { - /* If segment array is full, enlarge it */ - if(shm_numsegments == MAX_SEGMENTS) - { - ERROR("Can't map more segments : maximum number (%d) reached!\n", - MAX_SEGMENTS); - goto done; - } - shm_segment_bases[shm_numsegments] = - SHMMapSegment(header->next_segment); - if(!shm_segment_bases[shm_numsegments]) - { - ERROR("Failed to map next shared memory segment!\n"); - goto done; - } - - /* Get header of new segment to see if there are others after it */ - header = (SHM_SEGMENT_HEADER *) - shm_segment_bases[shm_numsegments].Load(); - shm_numsegments++; - num_new++; - } - retval = TRUE; -done: - SHMRelease(); - TRACE("Mapped %d new segments (total is now %d)\n", - num_new, shm_numsegments); - - return retval; -#else // !CORECLR return TRUE; -#endif // !CORECLR } /*++ @@ -1964,11 +1328,6 @@ Notes : --*/ static BOOL SHMAddSegment(void) { -#ifndef CORECLR - char segment_name[MAX_LONGPATH]; - char *suffix_start; - int fd_map; -#endif // !CORECLR LPVOID segment_base; SHM_SEGMENT_HEADER *header; SHM_FIRST_HEADER *first_header; @@ -2000,74 +1359,23 @@ static BOOL SHMAddSegment(void) TRACE("Creating SHM segment #%d\n", shm_numsegments); -#ifndef CORECLR - /* Create name template for mkstemp() */ - strcpy(segment_name, segment_name_template); - - suffix_start = segment_name + strlen(segment_name) - - SEGMENT_NAME_SUFFIX_LENGTH; - - fd_map = PAL_mkstemp(segment_name); - if(fd_map == -1) - { - ERROR("mkstemp() failed! error is %d (%s)\n", errno, strerror(errno)); - return FALSE; - } - if(-1 == fchmod(fd_map, 0600)) - { - ERROR("fchmod() failed! error is %d (%s)\n", errno, strerror(errno)); - close(fd_map); - PAL_unlink(segment_name); - return FALSE; - } - - /* Grow new file to desired size */ - if(!SHMInitSegmentFileSize(fd_map)) - { - ERROR("SHMInitSegmentFileSize() failed! error is %d (%s)\n", - errno, strerror(errno)); - close(fd_map); - PAL_unlink(segment_name); - return FALSE; - } - - /* mmap() the new file */ - segment_base = mmap(NULL, segment_size, PROT_READ|PROT_WRITE, - MAPFLAGS,fd_map, 0); - close(fd_map); -#else // !CORECLR segment_base = mmap(NULL, segment_size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE,-1, 0); -#endif // !CORECLR if(segment_base == MAP_FAILED) { ERROR("mmap() failed! error is %d (%s)\n", errno, strerror(errno)); -#ifndef CORECLR - PAL_unlink(segment_name); -#endif // !CORECLR return FALSE; } -#ifndef CORECLR - TRACE("Mapped SHM segment #%d at %p; name is %s\n", - shm_numsegments, segment_base, suffix_start); -#endif // !CORECLR - shm_segment_bases[shm_numsegments] = segment_base; /* Save name (well, suffix) of new segment in the header of the old last segment, so that other processes know where it is. */ header = (SHM_SEGMENT_HEADER *)shm_segment_bases[shm_numsegments-1].Load(); -#ifndef CORECLR - strcpy(header->next_segment, suffix_start); -#endif // !CORECLR /* Indicate that the new segment is the last one */ header = (SHM_SEGMENT_HEADER *)segment_base; -#ifndef CORECLR - header->next_segment[0] = '\0'; -#endif // !CORECLR /* We're now ready to update our memory pools */ @@ -2174,149 +1482,6 @@ static BOOL SHMAddSegment(void) return TRUE; } -#ifndef CORECLR -/*++ -SHMInitSegmentFileSize - -Grow a file to the size of a SHM segment - -Parameters : - int fd : File descriptor of file to initialize - -(no return value) - ---*/ -static BOOL SHMInitSegmentFileSize(int fd) -{ - /* Make sure the file starts out empty */ - if(ftruncate(fd, 0)==-1) - { - ERROR("ftruncate failed; error is %d (%s)\n", errno, strerror(errno)); - return FALSE; - } - - if(lseek(fd, 0, SEEK_SET)==-1) - { - ERROR("lseek failed; error is %d (%s)\n", errno, strerror(errno)); - return FALSE; - } - - /* grow the file size, by lseek. See lseek manual. */ - if(lseek(fd, segment_size, SEEK_SET)==-1) - { - ERROR("lseek failed; error is %d (%s)\n", errno, strerror(errno)); - return FALSE; - } - if(ftruncate(fd, segment_size)==-1) - { - ERROR("ftruncate failed; error is %d (%s)\n", errno, strerror(errno)); - return FALSE; - } - - return TRUE; -} - - -/*++ -SHMGetProcessList - -Read the list of registered PAL processes from the lockfile, stripping dead -processes along the way. - -Parameters : - int fd : file to read from - pid_t **process_list : pointer where process list will be placed - BOOL strip_me : if TRUE, the PID of the current process will be removed - -Return value : - -1 on failure - Number of PIDs in the list on success - ---*/ -static int SHMGetProcessList(int fd, pid_t **process_list, BOOL strip_me) -{ - int n_pal_processes; - pid_t *list; - pid_t me; - - me = gPID; - - if( 0 < read(fd, &n_pal_processes, sizeof(n_pal_processes)) - && n_pal_processes > 0) - { - /* read succesful, there are registered processes */ - int i,n; - - TRACE("LockFile says there are %d registered PAL processes.\n", - n_pal_processes); - - list = (pid_t *)PAL_malloc(n_pal_processes*sizeof(pid_t)); - if(!list) - { - ERROR("malloc() failed; error is %d (%s)\n", - errno, strerror(errno)); - return -1; - } - i = n = 0; - - /* read PIDs of registered processes into an array. We use this chance - to discard processes that died without unregistering themselves.*/ - for( i = 0; i< n_pal_processes; i++) - { - /* read 1 PID from lock file */ - - if(0 >= read(fd, &list[n], sizeof(pid_t))) - { - WARN("read() failed! error is %d (%s)\n", - errno, strerror(errno)); - break; - } - - /* Discard the PID of the currentprocess if required, and make sure - the PID is still valid. If invalid, kill(pid,0) fails and errno - is set to ESRCH */ - if(strip_me && list[n] == me) - { - TRACE("Removing current process (%08x) from list of registered " - "processes\n", list[n]); - } - else if(-1 != kill(list[n],0) || errno != ESRCH) - { - /* good PID : keep it*/ - n++; - } - else - { - TRACE("Discarding registered process 0x%08x : it's dead\n", - list[n]); - } - } - n_pal_processes = n; - if(n == 0) - { - TRACE("There are no registered PAL processes left.\n"); - PAL_free(list); - list = NULL; - } - else - { - TRACE("Number of registered PAL processes : %d\n", n_pal_processes); - } - } - else - { - /* read failed or number of processes was 0 : no registered processes */ - n_pal_processes = 0; - list = NULL; - TRACE("No PAL processes registered for shared memory access\n"); - } - - *process_list = list; - return n_pal_processes; -} -#endif // !CORECLR - - /*++ SHMStrDup @@ -2568,162 +1733,3 @@ void SHMAddNamedObject( SHMPTR shmNewNamedObject ) SHMRelease(); return; } - -#if !defined(CORECLR) && defined(_DEBUG) - -static DWORD alloc_log[SPS_LAST]; -static DWORD waste_log[SPS_LAST]; - -/*++ -init_waste - -Initialize emmory waste logging arays (set all to zero) - -(no parameters, no return value) ---*/ -static void init_waste(void) -{ - enum SHM_POOL_SIZES sps; - - for (sps = static_cast<SHM_POOL_SIZES>(0); sps < SPS_LAST; - sps = static_cast<SHM_POOL_SIZES>(sps + 1)) - { - alloc_log[sps] = 0; - waste_log[sps] = 0; - } -} - -/*++ -log_waste - -add waste information from 1 allocation to the log - -Parameters : - enum SHM_POOL_SIZES size : pool size selected for allocation - int waste : number of bytes wasted by allocation - -(no return value) - - Note: this could be a lot fancier : we could remember every single size - ever requested, and how often it was requested. do we need that much? - we could also keep a cumulative, system-wide total... ? ---*/ -static void log_waste(enum SHM_POOL_SIZES size, int waste) -{ - /* avoid overflowing*/ - if( ((DWORD)(~0) != alloc_log[size]) && - ((DWORD)(~0)-(DWORD)waste > waste_log[size])) - { - alloc_log[size]++; - waste_log[size]+=waste; - } - else - { - WARN("can't track shared memory usage : overflowing\n"); - } -} - -/*++ -save_waste - -output waste information to file (during process termination) - -(no parameters, no return value) ---*/ -static void save_waste(void) -{ - int fd; - FILE *log_file; - char file_name[MAX_LONGPATH]; - enum SHM_POOL_SIZES sps; - int avg; - LPSTR env_string; - - env_string = MiscGetenv(PAL_SAVE_WASTE); - - if(!env_string || env_string[0] =='\0' || env_string[0]=='0') - { - return; - } - - if ( !PALGetPalConfigDir( file_name, MAX_LONGPATH ) ) - { - ERROR( "Unable to determine the PAL config directory.\n" ); - return; - } - - if (strcat_s(file_name, sizeof(file_name), "/shm_waste_log") != SAFECRT_SUCCESS) - { - ERROR( "strcat_s failed!\n" ); - return; - } - - // Get an exclusive lock on the file -- we don't want - // interleaving between the output of multiple processes. -#ifdef O_EXLOCK - fd = PAL__open(file_name, O_APPEND|O_WRONLY|O_CREAT|O_EXLOCK, 0600); -#else // O_EXLOCK - fd = PAL__open(file_name, O_APPEND|O_WRONLY|O_CREAT, 0600); -#endif // O_EXLOCK - if(-1 == fd) - { - WARN("Unable to open log file %s : not logging shared memory waste. " - "PAL__open() failed with errno %d (%s)\n", - file_name, errno, strerror(errno)); - return; - } -#ifndef O_EXLOCK - if (lockf(fd, F_LOCK, 0) == -1) - { - WARN("Unable to lock log file %s. Not logging shared memory waste." - "lockf() failed with errno %d (%s)\n", - file_name, errno, strerror(errno)); - close(fd); - return; - } -#endif // O_EXLOCK - - /* open in append mode, so we preserve the output of other processes */ - log_file = fdopen(fd, "at"); - if( NULL == log_file) - { - WARN("Unable to open log file : not logging shared memory waste\n"); -#ifdef O_EXLOCK - flock(fd, LOCK_UN); -#else // O_EXLOCK - lockf(fd, F_ULOCK, 0); -#endif // O_EXLOCK - close(fd); - return; - } - TRACE("now writing shared memory waste log to file %s\n", file_name); - fprintf(log_file, "Shared memory waste for process %ld:\n", (long) gPID); - - /* output one line per block size */ - for (sps = static_cast<SHM_POOL_SIZES>(0); sps < SPS_LAST; - sps = static_cast<SHM_POOL_SIZES>(sps + 1)) - { - if(0 == alloc_log[sps]) - { - avg = 0; - } - else - { - avg = waste_log[sps]/alloc_log[sps]; - } - - fprintf(log_file, "size %4d : %8u bytes wasted in %8u blocks " - "(avg. %8d bytes/block)\n", - block_sizes[sps], waste_log[sps], alloc_log[sps], avg ); - } - fprintf(log_file, "\n"); - -#ifdef O_EXLOCK - flock(fd, LOCK_UN); -#else // O_EXLOCK - lockf(fd, F_ULOCK, 0); -#endif // O_EXLOCK - fclose(log_file); -} - -#endif // !defined(CORECLR) && defined(_DEBUG) diff --git a/src/pal/src/synchmgr/synchmanager.cpp b/src/pal/src/synchmgr/synchmanager.cpp index 0fb1b2d47e..42dfa2e0ad 100644 --- a/src/pal/src/synchmgr/synchmanager.cpp +++ b/src/pal/src/synchmgr/synchmanager.cpp @@ -2886,7 +2886,7 @@ namespace CorUnix PAL_ERROR palErr = NO_ERROR; int iProcessPipe, iBytesToWrite, iRetryCount; ssize_t sszRet; - char strPipeFilename[MAX_LONGPATH]; + char strPipeFilename[MAX_PATH]; BYTE * pPos = pMsg; bool fRet; CPalThread *pthrCurrent = InternalGetCurrentThread(); @@ -2895,7 +2895,7 @@ namespace CorUnix "SendMsgToRemoteWorker called with local process as " "target process\n"); - fRet = GetProcessPipeName(strPipeFilename, MAX_LONGPATH, dwProcessId); + fRet = GetProcessPipeName(strPipeFilename, MAX_PATH, dwProcessId); _ASSERT_MSG(fRet, "Failed to retrieve process pipe's name!\n"); @@ -3760,10 +3760,10 @@ namespace CorUnix #ifndef CORECLR int iPipeRd = -1, iPipeWr = -1; - char szPipeFilename[MAX_LONGPATH]; + char szPipeFilename[MAX_PATH]; /* Create the blocking pipe */ - if(!GetProcessPipeName(szPipeFilename, MAX_LONGPATH, gPID)) + if(!GetProcessPipeName(szPipeFilename, MAX_PATH, gPID)) { ERROR("couldn't get process pipe's name\n"); szPipeFilename[0] = 0; @@ -3903,9 +3903,9 @@ namespace CorUnix { PAL_ERROR palErr = NO_ERROR; #ifndef CORECLR - char szPipeFilename[MAX_LONGPATH]; + char szPipeFilename[MAX_PATH]; - if(GetProcessPipeName(szPipeFilename, MAX_LONGPATH, gPID)) + if(GetProcessPipeName(szPipeFilename, MAX_PATH, gPID)) { if (InternalUnlink(pthrCurrent, szPipeFilename) == -1) { @@ -3958,13 +3958,13 @@ namespace CorUnix int iDestSize, DWORD dwPid) { - CHAR config_dir[MAX_LONGPATH]; + CHAR config_dir[MAX_PATH]; int needed_size; _ASSERT_MSG(NULL != pDest, "Destination pointer is NULL!\n"); _ASSERT_MSG(0 < iDestSize,"Invalid buffer size %d\n", iDestSize); - if (!PALGetPalConfigDir(config_dir, MAX_LONGPATH)) + if (!PALGetPalConfigDir(config_dir, MAX_PATH)) { ASSERT("Unable to determine the PAL config directory.\n"); pDest[0] = '\0'; diff --git a/src/pal/src/thread/process.cpp b/src/pal/src/thread/process.cpp index 2830efef40..43b145d425 100644 --- a/src/pal/src/thread/process.cpp +++ b/src/pal/src/thread/process.cpp @@ -33,6 +33,7 @@ Abstract: #include "pal/utils.h" #include "pal/misc.h" #include "pal/virtual.h" +#include "pal/stackstring.hpp" #include <errno.h> #if HAVE_POLL @@ -560,7 +561,7 @@ CorUnix::InternalCreateProcess( int iFdErr = -1; pid_t processId; - char lpFileName[MAX_LONGPATH] ; + char * lpFileName = new char[MAX_LONGPATH]; char **lppArgv = NULL; UINT nArg; int iRet; @@ -581,6 +582,12 @@ CorUnix::InternalCreateProcess( palError = ERROR_INVALID_PARAMETER; goto InternalCreateProcessExit; } + + if (NULL == lpFileName) + { + palError = ERROR_NOT_ENOUGH_MEMORY; + goto InternalCreateProcessExit; + } if (0 != (dwCreationFlags & ~(CREATE_SUSPENDED|CREATE_NEW_CONSOLE))) { @@ -698,8 +705,8 @@ CorUnix::InternalCreateProcess( if ( PAL_GetPALDirectoryA( lpFileName, (MAX_LONGPATH - (strlen(PROCESS_PELOADER_FILENAME)+1)))) { - if ((strcat_s(lpFileName, sizeof(lpFileName), "/") != SAFECRT_SUCCESS) || - (strcat_s(lpFileName, sizeof(lpFileName), PROCESS_PELOADER_FILENAME) != SAFECRT_SUCCESS)) + if ((strcat_s(lpFileName, sizeof(char) * MAX_LONGPATH, "/") != SAFECRT_SUCCESS) || + (strcat_s(lpFileName, sizeof(char) * MAX_LONGPATH, PROCESS_PELOADER_FILENAME) != SAFECRT_SUCCESS)) { ERROR("strcpy_s/strcat_s failed!\n"); palError = ERROR_INTERNAL_ERROR; @@ -3202,7 +3209,8 @@ getFileName( { LPWSTR lpEnd; WCHAR wcEnd; - char lpFileName[MAX_LONGPATH]; + char * lpFileName; + PathCharString lpFileNamePS; char *lpTemp; if (lpApplicationName) @@ -3285,13 +3293,17 @@ getFileName( *lpEnd = 0x0000; /* Convert to ASCII */ - if (!WideCharToMultiByte(CP_ACP, 0, lpCommandLine, -1, - lpFileName, MAX_LONGPATH, NULL, NULL)) + int size = 0; + int length = (PAL_wcslen(lpCommandLine)+1) * sizeof(WCHAR); + lpFileName = lpFileNamePS.OpenStringBuffer(length); + if (!(size = WideCharToMultiByte(CP_ACP, 0, lpCommandLine, -1, + lpFileName, length, NULL, NULL))) { ASSERT("WideCharToMultiByte failure\n"); return FALSE; } + lpFileNamePS.CloseBuffer(size); /* restore last character */ *lpEnd = wcEnd; @@ -4068,4 +4080,4 @@ CorUnix::CProcProcessLocalData::~CProcProcessLocalData() DestroyProcessModules(pProcessModules); } } -
\ No newline at end of file + |