From d8aa9b52c3431a00825158ff4469e9dbeffd5710 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 10 Jan 2012 13:38:50 +0000 Subject: [PATCH] 2012-01-10 14:38 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/include/hbhrb.ch * harbour/src/vm/runner.c * disabled access to INIT and EXIT functions in HB_HRBGETFUNSYM() and HB_HRBGETFUNLIST() + added 2-nd parameter to HB_HRBGETFUNLIST() HB_HRBGETFUNLIST( [, ] ) -> is defined in hbhrb.ch: HB_HRB_FUNC_PUBLIC - locally defined public functions HB_HRB_FUNC_STATIC - locally defined static functions HB_HRB_FUNC_LOCAL - locally defined functions HB_HRB_FUNC_EXTERN - external functions used in HRB module --- harbour/ChangeLog | 13 +++++++++++++ harbour/include/hbhrb.ch | 7 +++++++ harbour/src/vm/runner.c | 22 +++++++++++++++++++--- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 81a15dfda2..d66f9d37a0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,19 @@ The license applies to all entries newer than 2009-04-28. */ +2012-01-10 14:38 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * harbour/include/hbhrb.ch + * harbour/src/vm/runner.c + * disabled access to INIT and EXIT functions in + HB_HRBGETFUNSYM() and HB_HRBGETFUNLIST() + + added 2-nd parameter to HB_HRBGETFUNLIST() + HB_HRBGETFUNLIST( [, ] ) -> + is defined in hbhrb.ch: + HB_HRB_FUNC_PUBLIC - locally defined public functions + HB_HRB_FUNC_STATIC - locally defined static functions + HB_HRB_FUNC_LOCAL - locally defined functions + HB_HRB_FUNC_EXTERN - external functions used in HRB module + 2012-01-09 22:20 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbtip/sendmail.prg * contrib/hbtip/smtpcli.prg diff --git a/harbour/include/hbhrb.ch b/harbour/include/hbhrb.ch index 628a9df2fa..17c61316ec 100644 --- a/harbour/include/hbhrb.ch +++ b/harbour/include/hbhrb.ch @@ -77,4 +77,11 @@ with unresolved or cross function references */ + +#define HB_HRB_FUNC_PUBLIC 0x1 /* locally defined public functions */ +#define HB_HRB_FUNC_STATIC 0x2 /* locally defined static functions */ +#define HB_HRB_FUNC_LOCAL 0x3 /* locally defined functions */ +#define HB_HRB_FUNC_EXTERN 0x4 /* external functions used in HRB module */ + + #endif /* HB_HRB_CH_ */ diff --git a/harbour/src/vm/runner.c b/harbour/src/vm/runner.c index 837376294c..01606b81df 100644 --- a/harbour/src/vm/runner.c +++ b/harbour/src/vm/runner.c @@ -857,7 +857,9 @@ HB_FUNC( HB_HRBGETFUNSYM ) for( nPos = 0, pSym = pHrbBody->pSymRead; nPos < pHrbBody->ulSymbols; ++pSym, ++nPos ) { - if( pSym->value.pFunPtr != NULL && hb_stricmp( szName, pSym->szName ) == 0 ) + if( pSym->value.pFunPtr != NULL && + ( pSym->scope.value & HB_FS_INITEXIT ) == 0 && + hb_stricmp( szName, pSym->szName ) == 0 ) { hb_itemPutSymbol( hb_stackReturnItem(), pSym ); break; @@ -878,11 +880,25 @@ HB_FUNC( HB_HRBGETFUNLIST ) HB_ULONG nPos; PHB_ITEM paList = hb_itemArrayNew( 0 ); PHB_ITEM pFuncName = hb_itemNew( NULL ); + int iType = hb_parni( 2 ); for( nPos = 0, pSym = pHrbBody->pSymRead; nPos < pHrbBody->ulSymbols; ++pSym, ++nPos ) { - if( pSym->value.pFunPtr != NULL ) - hb_arrayAdd( paList, hb_itemPutC( pFuncName, pSym->szName ) ); + if( pSym->value.pFunPtr != NULL && + ( pSym->scope.value & HB_FS_INITEXIT ) == 0 ) + { + if( iType == 0 || + ( ( iType & HB_HRB_FUNC_EXTERN ) && + ( pSym->scope.value & HB_FS_LOCAL ) == 0 ) || + ( ( pSym->scope.value & HB_FS_LOCAL ) && + ( ( ( iType & HB_HRB_FUNC_STATIC ) && + ( pSym->scope.value & HB_FS_STATIC ) ) || + ( ( iType & HB_HRB_FUNC_PUBLIC ) && + ( pSym->scope.value & HB_FS_STATIC ) == 0 ) ) ) ) + { + hb_arrayAdd( paList, hb_itemPutC( pFuncName, pSym->szName ) ); + } + } } hb_itemRelease( pFuncName );