Skip to content

Commit 00ec705

Browse files
committed
Use unsafe function alternatives because they're exclusive to Windows
1 parent 85d278b commit 00ec705

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

features/org.eclipse.equinox.executable.feature/library/eclipseCommon.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -544,17 +544,15 @@ _TCHAR* checkPath( _TCHAR* path, _TCHAR* programDir, int reverseOrder )
544544
_TCHAR* expandPath(_TCHAR* inPath) {
545545
_TCHAR buffer[MAX_PATH_LENGTH];
546546
_TCHAR variable[MAX_PATH_LENGTH];
547-
_TCHAR value[MAX_PATH_LENGTH];
548547

549548
_TCHAR* dstCur = &buffer[0];
550-
_TCHAR* dstEnd = &buffer[MAX_PATH_LENGTH];
551549
_TCHAR* srcCur = &inPath[0];
552550

553551
for(;;) {
554552
_TCHAR* start = _tcschr(srcCur, _T_ECLIPSE('%'));
555553
if (start == NULL) {
556554
// No more variables
557-
_tcsncpy_s(dstCur, dstEnd - dstCur, srcCur, _TRUNCATE);
555+
_tcscpy(dstCur, srcCur);
558556
return _tcsdup(buffer);
559557
}
560558
_TCHAR* end = _tcschr(start + 1, _T_ECLIPSE('%'));
@@ -563,18 +561,18 @@ _TCHAR* expandPath(_TCHAR* inPath) {
563561
*dstCur++ = *srcCur++;
564562
continue;
565563
}
566-
_tcsncpy_s(variable, end - start, start + 1, _TRUNCATE);
567-
size_t count;
568-
_tgetenv_s(&count, value, MAX_PATH_LENGTH, variable);
569-
if (count > 0) {
564+
_tcsncpy(variable, start + 1, end - start);
565+
variable[end - start - 1] = _T_ECLIPSE('\0');
566+
_TCHAR* value = _tgetenv(variable);
567+
if (value != NULL) {
570568
// Found a variable
571-
_tcsncpy_s(dstCur, dstEnd - dstCur, srcCur, start - srcCur);
569+
_tcsncpy(dstCur, srcCur, start - srcCur);
572570
dstCur += start - srcCur;
573-
_tcsncpy_s(dstCur, dstEnd - dstCur, value, _TRUNCATE);
571+
_tcscpy(dstCur, value);
574572
dstCur += _tcslen(value);
575573
} else {
576574
// Variable is not found
577-
_tcsncpy_s(dstCur, dstEnd - dstCur, srcCur, end - srcCur + 1);
575+
_tcsncpy(dstCur, srcCur, end - srcCur + 1);
578576
dstCur += end - srcCur + 1;
579577
}
580578
srcCur = end + 1;

0 commit comments

Comments
 (0)