diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.c b/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.c index 8316590660..e301c7adb2 100644 --- a/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.c +++ b/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.c @@ -544,17 +544,15 @@ _TCHAR* checkPath( _TCHAR* path, _TCHAR* programDir, int reverseOrder ) _TCHAR* expandPath(_TCHAR* inPath) { _TCHAR buffer[MAX_PATH_LENGTH]; _TCHAR variable[MAX_PATH_LENGTH]; - _TCHAR value[MAX_PATH_LENGTH]; _TCHAR* dstCur = &buffer[0]; - _TCHAR* dstEnd = &buffer[MAX_PATH_LENGTH]; _TCHAR* srcCur = &inPath[0]; for(;;) { _TCHAR* start = _tcschr(srcCur, _T_ECLIPSE('%')); if (start == NULL) { // No more variables - _tcsncpy_s(dstCur, dstEnd - dstCur, srcCur, _TRUNCATE); + _tcscpy(dstCur, srcCur); return _tcsdup(buffer); } _TCHAR* end = _tcschr(start + 1, _T_ECLIPSE('%')); @@ -563,18 +561,18 @@ _TCHAR* expandPath(_TCHAR* inPath) { *dstCur++ = *srcCur++; continue; } - _tcsncpy_s(variable, end - start, start + 1, _TRUNCATE); - size_t count; - _tgetenv_s(&count, value, MAX_PATH_LENGTH, variable); - if (count > 0) { + _tcsncpy(variable, start + 1, end - start); + variable[end - start - 1] = _T_ECLIPSE('\0'); + _TCHAR* value = _tgetenv(variable); + if (value != NULL) { // Found a variable - _tcsncpy_s(dstCur, dstEnd - dstCur, srcCur, start - srcCur); + _tcsncpy(dstCur, srcCur, start - srcCur); dstCur += start - srcCur; - _tcsncpy_s(dstCur, dstEnd - dstCur, value, _TRUNCATE); + _tcscpy(dstCur, value); dstCur += _tcslen(value); } else { // Variable is not found - _tcsncpy_s(dstCur, dstEnd - dstCur, srcCur, end - srcCur + 1); + _tcsncpy(dstCur, srcCur, end - srcCur + 1); dstCur += end - srcCur + 1; } srcCur = end + 1;