@@ -544,17 +544,15 @@ _TCHAR* checkPath( _TCHAR* path, _TCHAR* programDir, int reverseOrder )
544
544
_TCHAR * expandPath (_TCHAR * inPath ) {
545
545
_TCHAR buffer [MAX_PATH_LENGTH ];
546
546
_TCHAR variable [MAX_PATH_LENGTH ];
547
- _TCHAR value [MAX_PATH_LENGTH ];
548
547
549
548
_TCHAR * dstCur = & buffer [0 ];
550
- _TCHAR * dstEnd = & buffer [MAX_PATH_LENGTH ];
551
549
_TCHAR * srcCur = & inPath [0 ];
552
550
553
551
for (;;) {
554
552
_TCHAR * start = _tcschr (srcCur , _T_ECLIPSE ('%' ));
555
553
if (start == NULL ) {
556
554
// No more variables
557
- _tcsncpy_s (dstCur , dstEnd - dstCur , srcCur , _TRUNCATE );
555
+ _tcscpy (dstCur , srcCur );
558
556
return _tcsdup (buffer );
559
557
}
560
558
_TCHAR * end = _tcschr (start + 1 , _T_ECLIPSE ('%' ));
@@ -563,18 +561,18 @@ _TCHAR* expandPath(_TCHAR* inPath) {
563
561
* dstCur ++ = * srcCur ++ ;
564
562
continue ;
565
563
}
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 ) {
570
568
// Found a variable
571
- _tcsncpy_s ( dstCur , dstEnd - dstCur , srcCur , start - srcCur );
569
+ _tcsncpy ( dstCur , srcCur , start - srcCur );
572
570
dstCur += start - srcCur ;
573
- _tcsncpy_s (dstCur , dstEnd - dstCur , value , _TRUNCATE );
571
+ _tcscpy (dstCur , value );
574
572
dstCur += _tcslen (value );
575
573
} else {
576
574
// Variable is not found
577
- _tcsncpy_s ( dstCur , dstEnd - dstCur , srcCur , end - srcCur + 1 );
575
+ _tcsncpy ( dstCur , srcCur , end - srcCur + 1 );
578
576
dstCur += end - srcCur + 1 ;
579
577
}
580
578
srcCur = end + 1 ;
0 commit comments