2010-11-20 21:31 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/src/rdd/dbfntx/dbfntx1.c
  * harbour/src/rdd/dbfnsx/dbfnsx1.c
  * harbour/src/rdd/dbfcdx/dbfcdx1.c
  * harbour/contrib/rddads/ads1.c
    * casting cleanup

  * harbour/contrib/hbssl/ssl.c
    * use hb_itemGetWriteCL() instead of hb_itemUnShareString()
    ! do not allow to overwrite trailing 0 in string item - we
      have such code in FREAD() which uses hb_parcsize() instead
      of hb_parclen() but only for strict compatibility with CL5.x
      FREAD() function and it should not be replicated in any other
      code - strings without trailing 0 may cause GPF in some other
      code uisng [hb_]str*() C functions.
This commit is contained in:
Przemyslaw Czerpak
2010-11-20 20:31:45 +00:00
parent de66a718aa
commit e66e43e894
6 changed files with 62 additions and 45 deletions

View File

@@ -16,6 +16,22 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-11-20 21:31 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/rdd/dbfntx/dbfntx1.c
* harbour/src/rdd/dbfnsx/dbfnsx1.c
* harbour/src/rdd/dbfcdx/dbfcdx1.c
* harbour/contrib/rddads/ads1.c
* casting cleanup
* harbour/contrib/hbssl/ssl.c
* use hb_itemGetWriteCL() instead of hb_itemUnShareString()
! do not allow to overwrite trailing 0 in string item - we
have such code in FREAD() which uses hb_parcsize() instead
of hb_parclen() but only for strict compatibility with CL5.x
FREAD() function and it should not be replicated in any other
code - strings without trailing 0 may cause GPF in some other
code uisng [hb_]str*() C functions.
2010-11-20 19:08 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbgd/tests/tpoly.prg
* Applied patch from Tamas. Nicer flakes!

View File

@@ -466,24 +466,24 @@ HB_FUNC( SSL_READ )
if( ssl )
{
PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING );
int nRead;
PHB_ITEM pItem = hb_param( 2, HB_IT_STRING );
char * pBuffer;
HB_SIZE nLen;
int nRead = 0;
if( pBuffer && HB_ISBYREF( 2 ) )
if( pItem && HB_ISBYREF( 2 ) &&
hb_itemGetWriteCL( pItem, &pBuffer, &nLen ) )
{
nRead = HB_ISNUM( 3 ) ? hb_parni( 3 ) : ( int ) hb_parclen( 2 );
if( ( HB_SIZE ) nRead <= hb_parcsiz( 2 ) )
if( HB_ISNUM( 3 ) )
{
pBuffer = hb_itemUnShareString( pBuffer );
nRead = SSL_read( ssl, ( void * ) hb_itemGetCPtr( pBuffer ), nRead );
nRead = hb_parni( 3 );
if( nRead >= 0 && nRead < ( int ) nLen )
nLen = nRead;
}
else
nRead = 0;
nRead = nLen >= INT_MAX ? INT_MAX : ( int ) nLen;
nRead = SSL_read( ssl, pBuffer, nRead );
}
else
nRead = 0;
hb_retni( nRead );
}
@@ -500,24 +500,24 @@ HB_FUNC( SSL_PEEK )
if( ssl )
{
PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING );
int nRead;
PHB_ITEM pItem = hb_param( 2, HB_IT_STRING );
char * pBuffer;
HB_SIZE nLen;
int nRead = 0;
if( pBuffer && HB_ISBYREF( 2 ) )
if( pItem && HB_ISBYREF( 2 ) &&
hb_itemGetWriteCL( pItem, &pBuffer, &nLen ) )
{
nRead = HB_ISNUM( 3 ) ? hb_parni( 3 ) : ( int ) hb_parclen( 2 );
if( ( HB_SIZE ) nRead <= hb_parcsiz( 2 ) )
if( HB_ISNUM( 3 ) )
{
pBuffer = hb_itemUnShareString( pBuffer );
nRead = SSL_peek( ssl, ( void * ) hb_itemGetCPtr( pBuffer ), nRead );
nRead = hb_parni( 3 );
if( nRead >= 0 && nRead < ( int ) nLen )
nLen = nRead;
}
else
nRead = 0;
nRead = nLen >= INT_MAX ? INT_MAX : ( int ) nLen;
nRead = SSL_peek( ssl, pBuffer, nRead );
}
else
nRead = 0;
hb_retni( nRead );
}

View File

@@ -2925,7 +2925,7 @@ static HB_ERRCODE adsCreate( ADSAREAP pArea, LPDBOPENINFO pCreateInfo )
hConnection = HB_ADS_DEFCONNECTION( pCreateInfo->ulConnection );
pArea->szDataFileName = hb_strdup( ( char * ) pCreateInfo->abName );
pArea->szDataFileName = hb_strdup( pCreateInfo->abName );
fUnicode = HB_FALSE;
pArea->maxFieldLen = 0;
@@ -3363,7 +3363,8 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo )
/* See adsGettValue() for why we don't use pArea->area.uiMaxFieldNameLength here */
UNSIGNED16 usBufLen, usType, usDecimals;
DBFIELDINFO dbFieldInfo;
char szAlias[ HB_RDD_MAX_ALIAS_LEN + 1 ], * szFile;
char szAlias[ HB_RDD_MAX_ALIAS_LEN + 1 ];
const char * szFile;
HB_BOOL fDictionary = HB_FALSE, fUnicode = HB_FALSE;
HB_TRACE(HB_TR_DEBUG, ("adsOpen(%p)", pArea));
@@ -3381,7 +3382,7 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo )
#endif
#endif
}
szFile = ( char * ) pOpenInfo->abName;
szFile = pOpenInfo->abName;
if( pArea->hTable != 0 )
{
@@ -3423,7 +3424,7 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo )
}
else
{
commonError( pArea, EG_OPEN, ( HB_ERRCODE ) u32RetVal, 0, ( char * ) pOpenInfo->abName, 0, NULL );
commonError( pArea, EG_OPEN, ( HB_ERRCODE ) u32RetVal, 0, pOpenInfo->abName, 0, NULL );
return HB_FAILURE;
}
}
@@ -3452,7 +3453,7 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo )
/* 1001 and 7008 are standard ADS Open Errors that will usually be sharing issues */
HB_ERRCODE errOsCode = u32RetVal == 1001 || u32RetVal == 7008 ? 32 : 0;
fRetry = commonError( pArea, EG_OPEN, ( HB_ERRCODE ) u32RetVal, errOsCode,
( const char * ) pOpenInfo->abName,
pOpenInfo->abName,
EF_CANRETRY | EF_CANDEFAULT, &pError ) == E_RETRY;
}
else
@@ -3477,7 +3478,7 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo )
pOpenInfo->atomAlias = "";
}
pArea->szDataFileName = hb_strdup( ( char * ) ( pOpenInfo->abName ) );
pArea->szDataFileName = hb_strdup( pOpenInfo->abName );
pArea->hTable = hTable;
pArea->hStatement = hStatement;
pArea->hOrdCurrent = 0;
@@ -4131,7 +4132,7 @@ static HB_ERRCODE adsOrderCreate( ADSAREAP pArea, LPDBORDERCREATEINFO pOrderInfo
if( u32RetVal != AE_SUCCESS )
{
commonError( pArea, EG_CREATE, ( HB_ERRCODE ) u32RetVal, 0, ( char * ) pOrderInfo->abBagName, 0, NULL );
commonError( pArea, EG_CREATE, ( HB_ERRCODE ) u32RetVal, 0, pOrderInfo->abBagName, 0, NULL );
return HB_FAILURE;
}
else

View File

@@ -7434,7 +7434,7 @@ static HB_ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderI
PHB_ITEM pKeyExp, pForExp = NULL, pResult;
char szCpndTagName[ CDX_MAXTAGNAMELEN + 1 ], szTagName[ CDX_MAXTAGNAMELEN + 1 ];
char szFileName[ HB_PATH_MAX ], szTempFile[ HB_PATH_MAX ];
char *szFor = NULL;
const char *szFor = NULL;
LPCDXINDEX pIndex;
LPCDXTAG pTag;
HB_USHORT uiLen;
@@ -7450,7 +7450,7 @@ static HB_ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderI
if( hb_strlentrim( hb_itemGetCPtr( pOrderInfo->abExpr ) ) +
( pArea->dbfarea.area.lpdbOrdCondInfo && pArea->dbfarea.area.lpdbOrdCondInfo->abFor ?
hb_strlentrim( ( const char * ) pArea->dbfarea.area.lpdbOrdCondInfo->abFor ) : 0 ) >
hb_strlentrim( pArea->dbfarea.area.lpdbOrdCondInfo->abFor ) : 0 ) >
CDX_HEADEREXPLEN - 2 )
{
hb_cdxErrorRT( pArea, EG_DATAWIDTH, EDBF_KEYLENGTH, NULL, 0, 0, NULL );
@@ -7546,7 +7546,7 @@ static HB_ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderI
fExclusive = pArea->dbfarea.area.lpdbOrdCondInfo->fExclusive;
/* Check conditional expression */
szFor = ( char * ) pArea->dbfarea.area.lpdbOrdCondInfo->abFor;
szFor = pArea->dbfarea.area.lpdbOrdCondInfo->abFor;
if( szFor )
{
if( SELF_COMPILE( ( AREAP ) pArea, szFor ) == HB_FAILURE )

View File

@@ -6739,7 +6739,7 @@ static HB_ERRCODE hb_nsxOrderCreate( NSXAREAP pArea, LPDBORDERCREATEINFO pOrderI
fTemporary = pArea->dbfarea.area.lpdbOrdCondInfo->fTemporary;
fExclusive = pArea->dbfarea.area.lpdbOrdCondInfo->fExclusive;
/* Check conditional expression */
szFor = ( const char * ) pArea->dbfarea.area.lpdbOrdCondInfo->abFor;
szFor = pArea->dbfarea.area.lpdbOrdCondInfo->abFor;
if( pArea->dbfarea.area.lpdbOrdCondInfo->itmCobFor )
/* If we have a codeblock for the conditional expression, use it */
pForExp = hb_itemNew( pArea->dbfarea.area.lpdbOrdCondInfo->itmCobFor );
@@ -6797,10 +6797,10 @@ static HB_ERRCODE hb_nsxOrderCreate( NSXAREAP pArea, LPDBORDERCREATEINFO pOrderI
* 3. add the Tag to index file
*/
fNewFile = !pOrderInfo->atomBagName || !pOrderInfo->atomBagName[0];
hb_nsxCreateFName( pArea, ( const char * ) pOrderInfo->abBagName,
hb_nsxCreateFName( pArea, pOrderInfo->abBagName,
&fProd, szFileName, szTagName );
if( !fNewFile )
hb_strncpyUpperTrim( szTagName, ( const char * ) pOrderInfo->atomBagName, NSX_TAGNAME );
hb_strncpyUpperTrim( szTagName, pOrderInfo->atomBagName, NSX_TAGNAME );
pIndex = hb_nsxFindBag( pArea, szFileName );
if( pIndex )

View File

@@ -4616,7 +4616,7 @@ static int hb_ntxQuickSortCompare( LPNTXSORTINFO pSort, HB_BYTE * pKey1, HB_BYTE
{
int iLen = pSort->keyLen, i;
i = hb_ntxValCompare( pSort->pTag, (char *) pKey1, iLen, (char *) pKey2, iLen, HB_TRUE );
i = hb_ntxValCompare( pSort->pTag, (const char *) pKey1, iLen, (const char *) pKey2, iLen, HB_TRUE );
if( i == 0 )
{
if( pSort->pTag->fSortRec )
@@ -4861,7 +4861,7 @@ static void hb_ntxSortOrderPages( LPNTXSORTINFO pSort )
m = ( l + r ) >> 1;
ulPage = pSort->pSortedPages[ m ];
pTmp = &pSort->pSwapPage[ ulPage ].pKeyPool[ pSort->pSwapPage[ ulPage ].ulCurKey * ( iLen + 4 ) ];
i = hb_ntxValCompare( pSort->pTag, (char *) pKey, iLen, (char *) pTmp, iLen, HB_TRUE );
i = hb_ntxValCompare( pSort->pTag, (const char *) pKey, iLen, (const char *) pTmp, iLen, HB_TRUE );
if( i == 0 )
{
if( pSort->pTag->fSortRec )
@@ -4912,7 +4912,7 @@ static HB_BOOL hb_ntxSortKeyGet( LPNTXSORTINFO pSort, HB_BYTE ** pKeyVal, HB_ULO
m = ( l + r ) >> 1;
ulPg = pSort->pSortedPages[ m ];
pTmp = &pSort->pSwapPage[ ulPg ].pKeyPool[ pSort->pSwapPage[ ulPg ].ulCurKey * ( iLen + 4 ) ];
i = hb_ntxValCompare( pSort->pTag, (char *) pKey, iLen, (char *) pTmp, iLen, HB_TRUE );
i = hb_ntxValCompare( pSort->pTag, (const char *) pKey, iLen, (const char *) pTmp, iLen, HB_TRUE );
if( i == 0 )
{
if( pSort->pTag->fSortRec )
@@ -5152,7 +5152,7 @@ static void hb_ntxSortOut( LPNTXSORTINFO pSort )
}
if( fUnique )
{
if( ulKey != 0 && hb_ntxValCompare( pTag, (char *) pSort->pLastKey, iLen, (char *) pKeyVal, iLen, HB_TRUE ) == 0 )
if( ulKey != 0 && hb_ntxValCompare( pTag, (const char *) pSort->pLastKey, iLen, (const char *) pKeyVal, iLen, HB_TRUE ) == 0 )
{
continue;
}
@@ -5166,7 +5166,7 @@ static void hb_ntxSortOut( LPNTXSORTINFO pSort )
#ifdef HB_NTX_DEBUG_EXT
if( ulKey != 0 )
{
int i = hb_ntxValCompare( pTag, (char *) pSort->pLastKey, iLen, (char *) pKeyVal, iLen, HB_TRUE );
int i = hb_ntxValCompare( pTag, (const char *) pSort->pLastKey, iLen, (const char *) pKeyVal, iLen, HB_TRUE );
if( ! pTag->AscendKey )
i = -i;
if( i == 0 )
@@ -6301,7 +6301,7 @@ static HB_ERRCODE hb_ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderI
fTemporary = pArea->dbfarea.area.lpdbOrdCondInfo->fTemporary;
fExclusive = pArea->dbfarea.area.lpdbOrdCondInfo->fExclusive;
/* Check conditional expression */
szFor = ( char * ) pArea->dbfarea.area.lpdbOrdCondInfo->abFor;
szFor = pArea->dbfarea.area.lpdbOrdCondInfo->abFor;
if( pArea->dbfarea.area.lpdbOrdCondInfo->itmCobFor )
/* If we have a codeblock for the conditional expression, use it */
pForExp = hb_itemNew( pArea->dbfarea.area.lpdbOrdCondInfo->itmCobFor );