2008-08-23 11:38 UTC+0200 Viktor Szakats (harbour.01 syenar hu)

* source/pp/hbpp.c
   * source/vm/cmdarg.c
   * source/vm/memvars.c
   * source/rtl/dates.c
   * source/rtl/fstemp.c
   * source/rtl/gtchrmap.c
   * source/rtl/gtcrs/gtcrs.c
   * source/rtl/gtpca/gtpca.c
   * source/rtl/gtstd/gtstd.c
   * source/rdd/dbf1.c
   * source/rdd/dbfntx/dbfntx1.c
   * contrib/hbct/disk.c
   * contrib/hbfbird/firebird.c
   * contrib/hbw32/w32_ole.c
   * contrib/xhb/hboutdbg.c
   * contrib/examples/pp/hbppcore.c
     * strncpy() -> hb_strncpy()
     * strncat() -> hb_strncat()
     ! In most of these places the terminating zero 
       was not explicitly set by the caller before.

   * contrib/hbnf/getenvrn.c
   * contrib/hbw32/dllcall.c
   * contrib/hbw32/w32_ole.c
   * contrib/hbwhat32/_wincdlg.c
   * contrib/hbwhat32/_windll.c
   * contrib/hbwhat32/_winmain.c
   * contrib/hbziparch/hbzipnew.cpp
     ! strcpy() -> hb_strncpy()
     ! strcat() -> hb_strncat()
     ; TOFIX1: There are still two strcpy()s left in SQL_SPRINTF().
               Xavi, could you pls take a look at it?
     ; TOFIX2: There are still a few strcpy()s in hbwince.c and 
               dbgentry.c.

   * source/pp/hbpp.c
   * source/rtl/gtcrs/gtcrs.c
   * source/rtl/gtpca/gtpca.c
   * source/rtl/gtstd/gtstd.c
   * contrib/hbfbird/firebird.c
   * contrib/hbwhat32/_wincdlg.c
   * contrib/hbwhat32/_windll.c
     ! Fixed wrong buffer sizes (or no buffer limits) in some 
       string copy operations (potential buffer overruns).

   * contrib/hbnf/getenvrn.c
     ! Fixed bad leak in FT_GETE() on Win32 systems.

   * source/rtl/fstemp.c
     ! hb_fsTempName(): Fixed potential buffer overrun by one byte.
     * Minor formatting.

   * source/rtl/fstemp.c
   * source/rtl/hbffind.c
   * contrib/xhb/hboutdbg.c
     * Using sizeof() instead of explicit size in string copy operations.
     ; TODO: There is a lot more to fix like this.

   ; Przemek, could you double check these changes pls?
     I can send you the .diff if it helps.
This commit is contained in:
Viktor Szakats
2008-08-23 10:43:25 +00:00
parent b70cbd6a34
commit 23221548b4
24 changed files with 154 additions and 101 deletions

View File

@@ -8,11 +8,71 @@
2008-12-31 13:59 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2008-08-23 11:38 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* source/pp/hbpp.c
* source/vm/cmdarg.c
* source/vm/memvars.c
* source/rtl/dates.c
* source/rtl/fstemp.c
* source/rtl/gtchrmap.c
* source/rtl/gtcrs/gtcrs.c
* source/rtl/gtpca/gtpca.c
* source/rtl/gtstd/gtstd.c
* source/rdd/dbf1.c
* source/rdd/dbfntx/dbfntx1.c
* contrib/hbct/disk.c
* contrib/hbfbird/firebird.c
* contrib/hbw32/w32_ole.c
* contrib/xhb/hboutdbg.c
* contrib/examples/pp/hbppcore.c
* strncpy() -> hb_strncpy()
* strncat() -> hb_strncat()
! In most of these places the terminating zero
was not explicitly set by the caller before.
* contrib/hbnf/getenvrn.c
* contrib/hbw32/dllcall.c
* contrib/hbw32/w32_ole.c
* contrib/hbwhat32/_wincdlg.c
* contrib/hbwhat32/_windll.c
* contrib/hbwhat32/_winmain.c
* contrib/hbziparch/hbzipnew.cpp
! strcpy() -> hb_strncpy()
! strcat() -> hb_strncat()
; TOFIX1: There are still two strcpy()s left in SQL_SPRINTF().
Xavi, could you pls take a look at it?
; TOFIX2: There are still a few strcpy()s in hbwince.c and
dbgentry.c.
* source/pp/hbpp.c
* source/rtl/gtcrs/gtcrs.c
* source/rtl/gtpca/gtpca.c
* source/rtl/gtstd/gtstd.c
* contrib/hbfbird/firebird.c
* contrib/hbwhat32/_wincdlg.c
* contrib/hbwhat32/_windll.c
! Fixed wrong buffer sizes (or no buffer limits) in some
string copy operations (potential buffer overruns).
* contrib/hbnf/getenvrn.c
! Fixed bad leak in FT_GETE() on Win32 systems.
* source/rtl/fstemp.c
! hb_fsTempName(): Fixed potential buffer overrun by one byte.
* Minor formatting.
* source/rtl/fstemp.c
* source/rtl/hbffind.c
* contrib/xhb/hboutdbg.c
* Using sizeof() instead of explicit size in string copy operations.
; TODO: There is a lot more to fix like this.
2008-08-22 22:51 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* utils/hbtest/rt_array.prg
+ Added failing test case of doing AEval()
and resizing the evaluated array in the
eval codeblock.
; TOFIX
* utils/hbdoc/ft_funcs.prg
* utils/hbdoc/hbdoc.prg
@@ -25,7 +85,7 @@
* contrib/xhb/Makefile
* contrib/xhb/common.mak
+ contrib/xhb/arrayblk.prg
+ Added HB_ARRAYBLOCK()
+ Added HB_ARRAYBLOCK() from xhb.
2008-08-22 17:03 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* contrib/make_gcc_all.sh

View File

@@ -2376,13 +2376,13 @@ static int WorkMarkers( char **ptrmp, char **ptri, char *ptro, int *lenres, BOOL
if( ! com_or_tra )
{
/* translate */
strncpy( s_expreal + 1, *ptri, lenreal );
s_expreal[0] = '&';
s_expreal[lenreal + 1] = '\0';
*ptri += lenreal;
SearnRep( exppatt, s_expreal, lenreal + 1, ptro, lenres );
rezrestr = 1;
break;
hb_strncpy( s_expreal + 1, *ptri, lenreal );
s_expreal[0] = '&';
s_expreal[lenreal + 1] = '\0';
*ptri += lenreal;
SearnRep( exppatt, s_expreal, lenreal + 1, ptro, lenres );
rezrestr = 1;
break;
}
else
{
@@ -2406,7 +2406,7 @@ static int WorkMarkers( char **ptrmp, char **ptri, char *ptro, int *lenres, BOOL
* is preprocessed into:
* &a ++( b )
*/
strncpy( s_expreal + 1, *ptri, lenreal );
hb_strncpy( s_expreal + 1, *ptri, lenreal );
s_expreal[0] = '&';
s_expreal[lenreal + 1] = '\0';
*ptri += lenreal;

View File

@@ -217,12 +217,12 @@ HB_FUNC( VOLUME )
{
if( fname->szPath )
{
strncpy( sRootBuf, fname->szPath, 3 );
hb_strncpy( sRootBuf, fname->szPath, 3 );
sRoot = sRootBuf;
}
if( fname->szName )
{
strncpy( sVolNameBuf, fname->szName, 11 );
hb_strncpy( sVolNameBuf, fname->szName, 11 );
sVolName = sVolNameBuf;
}
@@ -230,7 +230,7 @@ HB_FUNC( VOLUME )
}
else
{
strncpy( sVolNameBuf, ( char * ) sDiskName, 11 );
hb_strncpy( sVolNameBuf, ( char * ) sDiskName, 11 );
sVolName = sVolNameBuf;
}
if( fFree )

View File

@@ -118,12 +118,12 @@ HB_FUNC( FBCONNECT )
dpb[ i++ ] = isc_dpb_user_name;
len = strlen( user );
dpb[ i++ ] = ( char ) len;
strncpy( &( dpb[ i ] ), user, len );
hb_strncpy( &( dpb[ i ] ), user, len );
i += len;
dpb[ i++ ] = isc_dpb_password;
len = strlen( passwd );
dpb[ i++ ] = len;
strncpy( &( dpb[ i ] ), passwd, len );
hb_strncpy( &( dpb[ i ] ), passwd, len );
i += len;
if( isc_attach_database( status, 0, db_connect, &db, i, dpb ) )
@@ -253,7 +253,7 @@ HB_FUNC( FBQUERY )
PHB_ITEM aTemp;
PHB_ITEM aNew;
strncpy( sel_str, hb_parcx( 2 ), sizeof( sel_str ) );
hb_strncpy( sel_str, hb_parcx( 2 ), sizeof( sel_str ) - 1 );
if( ISPOINTER( 4 ) )
{

View File

@@ -164,9 +164,9 @@ HB_FUNC( FT_GETE )
if( rettype == CHARTYPE )
{
/* tack string onto end of buffer */
strcat( buffer, environ[x] );
hb_strncat( buffer, environ[x], buffsize );
/* add crlf at end of each string */
strcat( buffer, CRLF );
hb_strncat( buffer, CRLF, buffsize );
}
else if( rettype == ARRAYTYPE )
/* store string to next array element */
@@ -204,29 +204,26 @@ HB_FUNC( FT_GETE )
{
for( sCurEnv = ( LPSTR ) lpEnviron; *sCurEnv; sCurEnv++ )
{
if( !*sCurEnv )
/* null string, we're done */
break;
{
if( !*sCurEnv )
/* null string, we're done */
break;
/* add length of this string plus 2 for the crlf */
buffsize += ( strlen( ( char * ) sCurEnv ) + 2 );
}
/* add 1 more byte for final nul character */
buffsize++;
/* add length of this string plus 2 for the crlf */
buffsize += ( strlen( ( char * ) sCurEnv ) + 2 );
/* now allocate that much memory and make sure 1st byte is a nul */
buffer = ( char * ) hb_xalloc( buffsize );
strcpy( buffer, "\0" );
while( *sCurEnv )
sCurEnv++;
}
/* add 1 more byte for final nul character */
buffsize++;
/* now allocate that much memory and make sure 1st byte is a nul */
buffer = ( char * ) hb_xalloc( buffsize + 1 );
buffer[0] = '\0';
}
x = 0;
for( sCurEnv = ( LPSTR ) lpEnviron; *sCurEnv; sCurEnv++ )
{
if( !*sCurEnv )
/* null string, we're done */
break;
@@ -234,9 +231,9 @@ HB_FUNC( FT_GETE )
if( rettype == CHARTYPE )
{
/* tack string onto end of buffer */
strcat( buffer, ( char * ) sCurEnv );
hb_strncat( buffer, ( char * ) sCurEnv, buffsize );
/* add crlf at end of each string */
strcat( buffer, CRLF );
hb_strncat( buffer, CRLF, buffsize );
}
if( rettype == ARRAYTYPE )

View File

@@ -755,7 +755,7 @@ HB_FUNC( DLLPREPARECALL )
xec->lpFunc = ( LPVOID ) GetProcAddress( xec->hDLL, xec->cProc ? ( LPCSTR ) xec->cProc : ( LPCSTR ) ( HB_PTRDIFF ) xec->wOrdinal );
if( ! xec->lpFunc && xec->cProc ) /* try with ANSI suffix? */
xec->lpFunc = ( LPVOID ) GetProcAddress( xec->hDLL, ( LPCSTR ) strcat( xec->cProc, "A" ) );
xec->lpFunc = ( LPVOID ) GetProcAddress( xec->hDLL, ( LPCSTR ) hb_strncat( xec->cProc, "A", hb_parclen( 3 ) + 1 ) );
if( xec->lpFunc )
{
@@ -810,7 +810,7 @@ static LPVOID hb_getprocaddress( HMODULE hDLL, int i )
{
char * pszFuncName = ( char * ) hb_xgrab( hb_parclen( i ) + 2 );
hb_strncpy( pszFuncName, hb_parc( i ), hb_parclen( i ) );
lpFunction = ( LPVOID ) GetProcAddress( hDLL, strcat( pszFuncName, "A" ) );
lpFunction = ( LPVOID ) GetProcAddress( hDLL, hb_strncat( pszFuncName, "A", hb_parclen( i ) + 1 ) );
hb_xfree( pszFuncName );
}

View File

@@ -1660,7 +1660,7 @@ static void OleThrowError( void )
// Intentional to avoid report of memory leak if fatal error.
char *sTemp = hb_oleWideToAnsi( excep.bstrDescription );
sDescription = (char *) malloc( strlen( sTemp ) + 1 );
strcpy( sDescription, sTemp );
hb_strncpy( sDescription, sTemp, strlen( sTemp ) );
hb_xfree( sTemp );
}
else
@@ -1967,9 +1967,9 @@ OleGetID:
sOleClassName = (char *) hb_xgrab( iClassNameLen + 1 + iMsgNameLen + 1 );
strncpy( sOleClassName, hb_parc( - 1 ), iClassNameLen );
hb_strncpy( sOleClassName, hb_parc( - 1 ), iClassNameLen );
sOleClassName[ iClassNameLen ] = ':';
strcpy( sOleClassName + iClassNameLen + 1, hb_itemGetSymbol( hb_stackBaseItem() )->szName );
hb_strncpy( sOleClassName + iClassNameLen + 1, hb_itemGetSymbol( hb_stackBaseItem() )->szName, iMsgNameLen );
//HB_TRACE(HB_TR_INFO, ("Class: '%s'\n", sOleClassName));

View File

@@ -197,9 +197,9 @@ HB_FUNC( CHOOSECOLOR )
HB_FUNC( _GETOPENFILENAME )
{
OPENFILENAME ofn;
char *szFileName =(char*) hb_xgrab( hb_parcsiz(2));
char *szFileName = ( char * ) hb_xgrab( hb_parclen( 2 ) + 1 );
strcpy( szFileName, hb_parcx( 2 ) );
hb_strncpy( szFileName, hb_parcx( 2 ), hb_parclen( 2 ) );
ZeroMemory( &ofn, sizeof(ofn) );
ofn.hInstance = GetModuleHandle(NULL) ;
@@ -236,10 +236,10 @@ HB_FUNC( _GETOPENFILENAME )
HB_FUNC( _GETSAVEFILENAME )
{
OPENFILENAME ofn;
char szFileName[MAX_PATH+1] ;
strcpy( szFileName, hb_parc (2) );
ZeroMemory(&ofn, sizeof(ofn));
ofn.hInstance = GetModuleHandle(NULL) ;
char szFileName[ MAX_PATH + 1 ];
hb_strncpy( szFileName, hb_parc( 2 ), MAX_PATH );
ZeroMemory( &ofn, sizeof( ofn ) );
ofn.hInstance = GetModuleHandle(NULL);
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = ISNIL (1) ? GetActiveWindow() : (HWND) hb_parnl(1);
ofn.lpstrTitle = hb_parc (3);

View File

@@ -84,7 +84,7 @@ HB_FUNC( FREELIBRARYANDEXITTHREAD )
HB_FUNC( GETPROCADDRESS )
{
ULONG dwProcAddr;
char cFuncName[MAX_PATH];
char cFuncName[ MAX_PATH + 1 ];
if ((dwProcAddr = (ULONG) GetProcAddress( (HMODULE) hb_parnl(1),
ISCHAR( 2 ) ? (LPCSTR) hb_parcx(2) :
@@ -92,10 +92,10 @@ HB_FUNC( GETPROCADDRESS )
{
if ( ISCHAR( 2 ) )
{
// try forced ANSI flavour ?
strcpy(cFuncName, hb_parcx(2));
strcat(cFuncName, "A");
dwProcAddr = (ULONG) GetProcAddress((HMODULE) hb_parnl(1), cFuncName);
// try forced ANSI flavour ?
hb_strncpy( cFuncName, hb_parcx( 2 ), sizeof( cFuncName ) - 2 );
hb_strncat( cFuncName, "A", sizeof( cFuncName ) - 1 );
dwProcAddr = (ULONG) GetProcAddress((HMODULE) hb_parnl(1), cFuncName);
}
}

View File

@@ -76,7 +76,7 @@ int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */
hb_hPrevInstance = hPrevInstance;
hb_iCmdShow = iCmdShow;
strcpy( pArgs, lpCmdLine );
hb_strncpy( pArgs, lpCmdLine, strlen( lpCmdLine ) );
HB_TRACE(HB_TR_DEBUG, ("WinMain(%p, %p, %s, %d)", hInstance, hPrevInstance, lpCmdLine, iCmdShow));

View File

@@ -876,7 +876,7 @@ const char * hb_GetZipComment( char * szFile )
szReturn = "";
szTempR = ( char * ) hb_xgrab( strlen( ( const char * ) szReturn ) + 1 );
strcpy( szTempR, ( char * ) szReturn );
hb_strncpy( szTempR, ( char * ) szReturn, strlen( ( const char * ) szReturn ) );
szZip.Close();

View File

@@ -146,7 +146,7 @@ HB_FUNC( HB_OUTDEBUGNAME )
if ( s_iDebugFd == 0 && pName != NULL)
{
strncpy( s_szDebugName, hb_itemGetCPtr( pName ), 127 );
hb_strncpy( s_szDebugName, hb_itemGetCPtr( pName ), sizeof( s_szDebugName ) - 1 );
s_iUseDebugName = 1;
hb_retl( TRUE );

View File

@@ -171,11 +171,11 @@ static int hb_pp_writeRules( FILE * fout, PHB_PP_RULE pFirst, char * szName )
if( pRule->pMatch )
snprintf( szMatch, sizeof( szMatch ), "s_%cm%03d", szName[0], iRule );
else
strncpy( szMatch, "NULL ", sizeof( szResult ) );
hb_strncpy( szMatch, "NULL ", sizeof( szMatch ) - 1 );
if( pRule->pResult )
snprintf( szResult, sizeof( szResult ), "s_%cr%03d", szName[0], iRule );
else
strncpy( szResult, "NULL ", sizeof( szResult ) );
hb_strncpy( szResult, "NULL ", sizeof( szResult ) - 1 );
ulRepeatBits = 0;
for( u = 0, ulBit = 1; u < pRule->markers; ++u, ulBit <<= 1 )

View File

@@ -2749,7 +2749,7 @@ static ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo )
}
else
{
hb_strncpy( ( char * ) szFileName, ( char * ) pCreateInfo->abName, _POSIX_PATH_MAX );
hb_strncpy( ( char * ) szFileName, ( char * ) pCreateInfo->abName, sizeof( szFileName ) - 1 );
}
hb_xfree( pFileName );
@@ -2883,8 +2883,8 @@ static ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo )
for( uiCount = 0; uiCount < pArea->uiFieldCount; uiCount++ )
{
LPFIELD pField = pArea->lpFields + uiCount;
strncpy( ( char * ) pThisField->bName,
hb_dynsymName( ( PHB_DYNS ) pField->sym ), 10 );
hb_strncpy( ( char * ) pThisField->bName,
hb_dynsymName( ( PHB_DYNS ) pField->sym ), 10 );
pArea->pFieldOffset[ uiCount ] = pArea->uiRecordLen;
/* field offset */
if( pArea->bTableType == DB_DBF_VFP )

View File

@@ -1600,7 +1600,7 @@ static void hb_ntxIndexTagAdd( LPNTXINDEX pIndex, LPTAGINFO pTag )
{
++iTags;
HB_PUT_LE_UINT16( lpCTX->ntags, iTags );
strncpy( ( char * ) pTagItem->tag_name, pTag->TagName, NTX_MAX_TAGNAME );
hb_strncpy( ( char * ) pTagItem->tag_name, pTag->TagName, NTX_MAX_TAGNAME );
}
HB_PUT_LE_UINT32( pTagItem->tag_header, pTag->HeadBlock );
pIndex->Update = TRUE;
@@ -1708,11 +1708,11 @@ static ERRCODE hb_ntxTagHeaderSave( LPTAGINFO pTag )
Header.unique[0] = pTag->UniqueKey ? 1 : 0;
Header.descend[0] = pTag->AscendKey ? 0 : 1;
Header.custom[0] = pTag->Custom ? 1 : 0;
strncpy( ( char * ) Header.key_expr, pTag->KeyExpr, NTX_MAX_EXP );
hb_strncpy( ( char * ) Header.key_expr, pTag->KeyExpr, NTX_MAX_EXP );
if( pTag->ForExpr )
strncpy( ( char * ) Header.for_expr, pTag->ForExpr, NTX_MAX_EXP );
hb_strncpy( ( char * ) Header.for_expr, pTag->ForExpr, NTX_MAX_EXP );
if( pTag->fTagName )
strncpy( ( char * ) Header.tag_name, pTag->TagName, NTX_MAX_TAGNAME );
hb_strncpy( ( char * ) Header.tag_name, pTag->TagName, NTX_MAX_TAGNAME );
iSize = sizeof( NTXHEADER );
}

View File

@@ -218,7 +218,7 @@ HB_EXPORT char * hb_dateFormat( const char * szDate, char * szFormattedDate, con
{
/* Not a valid date string, so return a blank date with separators */
format_count = size; /* size is either 8 or 10 */
strncpy( szFormattedDate, szDateFormat, size );
hb_strncpy( szFormattedDate, szDateFormat, size );
for( digit_count = 0; digit_count < size; digit_count++ )
{

View File

@@ -73,9 +73,9 @@ static BOOL hb_fsTempName( BYTE * pszBuffer, const BYTE * pszDir, const BYTE * p
char cTempDir[ _POSIX_PATH_MAX + 1 ];
if( pszDir != NULL && pszDir[0] != '\0' )
if( pszDir != NULL && pszDir[ 0 ] != '\0' )
{
strncpy( (char *) cTempDir, (const char *) pszDir, _POSIX_PATH_MAX + 1 );
hb_strncpy( ( char * ) cTempDir, ( const char * ) pszDir, sizeof( cTempDir ) - 1 );
}
else
{
@@ -174,9 +174,9 @@ HB_EXPORT FHANDLE hb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix,
do
{
pszName[0] = '\0';
pszName[ 0 ] = '\0';
if( pszDir != NULL && pszDir[0] != '\0' )
if( pszDir != NULL && pszDir[ 0 ] != '\0' )
{
hb_strncpy( ( char * ) pszName, ( char * ) pszDir, _POSIX_PATH_MAX );
}
@@ -190,8 +190,8 @@ HB_EXPORT FHANDLE hb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix,
if( !fsGetTempDirByCase( pszName, P_tmpdir ) )
#endif
{
pszName[0] = '.';
pszName[1] = '\0';
pszName[ 0 ] = '.';
pszName[ 1 ] = '\0';
}
}
if( pszTmpDir )
@@ -222,8 +222,8 @@ HB_EXPORT FHANDLE hb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix,
hb_set.HB_SET_DIRCASE != HB_SET_CASE_UPPER )
{
hb_strncat( ( char * ) pszName, "XXXXXX", _POSIX_PATH_MAX );
fd = (FHANDLE) mkstemp( ( char * ) pszName );
hb_fsSetIOError( fd != (FHANDLE) -1, 0 );
fd = ( FHANDLE ) mkstemp( ( char * ) pszName );
hb_fsSetIOError( fd != ( FHANDLE ) -1, 0 );
}
else
#endif
@@ -242,7 +242,7 @@ HB_EXPORT FHANDLE hb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix,
fd = hb_fsCreateEx( pszName, ulAttr, FO_EXCLUSIVE | FO_EXCL );
}
if( fd != (FHANDLE) FS_ERROR )
if( fd != ( FHANDLE ) FS_ERROR )
return fd;
}
while( --iAttemptLeft );

View File

@@ -382,8 +382,7 @@ static int hb_gt_chrmapread( const char *pszFile, const char *pszTerm, int *nTra
if( fp != NULL )
{
strncpy( buf, pszTerm, sizeof( buf ) );
buf[ sizeof( buf ) - 1 ] = '\0';
hb_strncpy( buf, pszTerm, sizeof( buf ) - 1 );
isTerm = 0;
pTerm = buf;
while( pTerm )
@@ -431,8 +430,8 @@ int hb_gt_chrmapinit( int *piTransTbl, const char *pszTerm, BOOL fSetACSC )
if( pszFile != NULL && sizeof( szFile ) >
strlen( pszFile ) + strlen( s_szDefaultCharMapFile ) )
{
hb_strncpy( szFile, pszFile, _POSIX_PATH_MAX );
hb_strncat( szFile, s_szDefaultCharMapFile, _POSIX_PATH_MAX );
hb_strncpy( szFile, pszFile, sizeof( szFile ) - 1 );
hb_strncat( szFile, s_szDefaultCharMapFile, sizeof( szFile ) - 1 );
nRet = hb_gt_chrmapread( szFile, pszTerm, piTransTbl );
}
}

View File

@@ -1935,8 +1935,7 @@ static InOutBase *create_ioBase( char *term, int infd, int outfd, int errfd,
{
if ( ( i = ptr - term ) >= sizeof( buf ) )
i = sizeof( buf ) - 1;
strncpy( buf, term, i );
buf[i] = '\0';
hb_strncpy( buf, term, i );
if ( i )
crsterm = buf;
}
@@ -2824,10 +2823,10 @@ static BOOL hb_gt_crs_SetDispCP( PHB_GT pGT, char *pszTermCDP, char *pszHostCDP,
char *pszHostLetters = ( char * ) hb_xgrab( cdpHost->nChars * 2 + 1 );
char *pszTermLetters = ( char * ) hb_xgrab( cdpTerm->nChars * 2 + 1 );
strncpy( pszHostLetters, cdpHost->CharsUpper, cdpHost->nChars + 1 );
strncat( pszHostLetters, cdpHost->CharsLower, cdpHost->nChars + 1 );
strncpy( pszTermLetters, cdpTerm->CharsUpper, cdpTerm->nChars + 1 );
strncat( pszTermLetters, cdpTerm->CharsLower, cdpTerm->nChars + 1 );
hb_strncpy( pszHostLetters, cdpHost->CharsUpper, cdpHost->nChars * 2 );
hb_strncat( pszHostLetters, cdpHost->CharsLower, cdpHost->nChars * 2 );
hb_strncpy( pszTermLetters, cdpTerm->CharsUpper, cdpTerm->nChars * 2 );
hb_strncat( pszTermLetters, cdpTerm->CharsLower, cdpTerm->nChars * 2 );
setDispTrans( s_ioBase, pszHostLetters, pszTermLetters, fBox ? 1 : 0 );
@@ -2868,10 +2867,10 @@ static BOOL hb_gt_crs_SetKeyCP( PHB_GT pGT, char *pszTermCDP, char *pszHostCDP )
char *pszHostLetters = ( char * ) hb_xgrab( cdpHost->nChars * 2 + 1 );
char *pszTermLetters = ( char * ) hb_xgrab( cdpTerm->nChars * 2 + 1 );
strncpy( pszHostLetters, cdpHost->CharsUpper, cdpHost->nChars + 1 );
strncat( pszHostLetters, cdpHost->CharsLower, cdpHost->nChars + 1 );
strncpy( pszTermLetters, cdpTerm->CharsUpper, cdpTerm->nChars + 1 );
strncat( pszTermLetters, cdpTerm->CharsLower, cdpTerm->nChars + 1 );
hb_strncpy( pszHostLetters, cdpHost->CharsUpper, cdpHost->nChars * 2 );
hb_strncat( pszHostLetters, cdpHost->CharsLower, cdpHost->nChars * 2 );
hb_strncpy( pszTermLetters, cdpTerm->CharsUpper, cdpTerm->nChars * 2 );
hb_strncat( pszTermLetters, cdpTerm->CharsLower, cdpTerm->nChars * 2 );
setKeyTrans( s_ioBase, ( unsigned char * ) pszTermLetters,
( unsigned char * ) pszHostLetters );

View File

@@ -760,10 +760,10 @@ static BOOL hb_gt_pca_SetKeyCP( PHB_GT pGT, char *pszTermCDP, char *pszHostCDP )
char *pszHostLetters = ( char * ) hb_xgrab( cdpHost->nChars * 2 + 1 );
char *pszTermLetters = ( char * ) hb_xgrab( cdpTerm->nChars * 2 + 1 );
strncpy( pszHostLetters, cdpHost->CharsUpper, cdpHost->nChars + 1 );
strncat( pszHostLetters, cdpHost->CharsLower, cdpHost->nChars + 1 );
strncpy( pszTermLetters, cdpTerm->CharsUpper, cdpTerm->nChars + 1 );
strncat( pszTermLetters, cdpTerm->CharsLower, cdpTerm->nChars + 1 );
hb_strncpy( pszHostLetters, cdpHost->CharsUpper, cdpHost->nChars * 2 );
hb_strncat( pszHostLetters, cdpHost->CharsLower, cdpHost->nChars * 2 );
hb_strncpy( pszTermLetters, cdpTerm->CharsUpper, cdpTerm->nChars * 2 );
hb_strncat( pszTermLetters, cdpTerm->CharsLower, cdpTerm->nChars * 2 );
hb_gt_pca_setKeyTrans( pszTermLetters, pszHostLetters );

View File

@@ -553,10 +553,10 @@ static BOOL hb_gt_std_SetKeyCP( PHB_GT pGT, char *pszTermCDP, char *pszHostCDP )
char *pszHostLetters = ( char * ) hb_xgrab( cdpHost->nChars * 2 + 1 );
char *pszTermLetters = ( char * ) hb_xgrab( cdpTerm->nChars * 2 + 1 );
strncpy( pszHostLetters, cdpHost->CharsUpper, cdpHost->nChars + 1 );
strncat( pszHostLetters, cdpHost->CharsLower, cdpHost->nChars + 1 );
strncpy( pszTermLetters, cdpTerm->CharsUpper, cdpTerm->nChars + 1 );
strncat( pszTermLetters, cdpTerm->CharsLower, cdpTerm->nChars + 1 );
hb_strncpy( pszHostLetters, cdpHost->CharsUpper, cdpHost->nChars * 2 );
hb_strncat( pszHostLetters, cdpHost->CharsLower, cdpHost->nChars * 2 );
hb_strncpy( pszTermLetters, cdpTerm->CharsUpper, cdpTerm->nChars * 2 );
hb_strncat( pszTermLetters, cdpTerm->CharsLower, cdpTerm->nChars * 2 );
hb_gt_std_setKeyTrans( HB_GTSTD_GET( pGT ), pszTermLetters, pszHostLetters );

View File

@@ -466,7 +466,7 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind )
if( bFound )
{
hb_strncpy( ffind->szName, info->entry.ff_name, _POSIX_PATH_MAX );
hb_strncpy( ffind->szName, info->entry.ff_name, sizeof( ffind->szName ) - 1 );
ffind->size = info->entry.ff_fsize;
raw_attr = info->entry.ff_attrib;
@@ -531,7 +531,7 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind )
stat( info->entry.achName, &sStat );
hb_strncpy( ffind->szName, info->entry.achName, _POSIX_PATH_MAX );
hb_strncpy( ffind->szName, info->entry.achName, sizeof( ffind->szName ) - 1 );
ffind->size = sStat.st_size;
raw_attr = info->entry.attrFile;
@@ -601,7 +601,7 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind )
if( bFound )
{
hb_strncpy( ffind->szName, info->pFindFileData.cFileName, _POSIX_PATH_MAX );
hb_strncpy( ffind->szName, info->pFindFileData.cFileName, sizeof( ffind->szName ) - 1 );
if( info->pFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
ffind->size = 0;
@@ -715,7 +715,7 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind )
if( stat( dirname, &sStat ) == 0 )
#endif
{
hb_strncpy( ffind->szName, info->entry->d_name, _POSIX_PATH_MAX );
hb_strncpy( ffind->szName, info->entry->d_name, sizeof( ffind->szName ) - 1 );
ffind->size = sStat.st_size;
raw_attr = sStat.st_mode;

View File

@@ -226,8 +226,7 @@ static char * hb_cmdargGet( const char * pszName, BOOL bRetValue )
ulLen = pszEnd > pszNext ? pszEnd - pszNext : 0;
pszRetVal = ( char * ) hb_xgrab( ulLen + 1 );
strncpy( pszRetVal, pszNext, ulLen );
pszRetVal[ ulLen ] = '\0';
hb_strncpy( pszRetVal, pszNext, ulLen );
}
else
pszRetVal = "";

View File

@@ -1299,8 +1299,7 @@ static HB_DYNS_FUNC( hb_memvarSave )
memset( buffer, 0, HB_MEM_REC_LEN );
/* NOTE: Save only the first 10 characters of the name */
strncpy( ( char * ) buffer, pDynSymbol->pSymbol->szName, 10 );
buffer[ 10 ] = '\0';
hb_strncpy( ( char * ) buffer, pDynSymbol->pSymbol->szName, 10 );
if( HB_IS_STRING( pItem ) && ( hb_itemGetCLen( pItem ) + 1 ) <= SHRT_MAX )
{