diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 84da2732d8..e8d7d26268 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,31 @@ The license applies to all entries newer than 2009-04-28. */ +2012-01-11 19:25 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) + * contrib/hbcairo/core.c + ! fixed typo + + * contrib/hbssl/ssl.c + ! fixed typo in SSL_GET_MODE() + + * contrib/hbssl/hbssl.h + * contrib/hbssl/x509.c + * contrib/hbssl/ssl.c + + implemented release option for X509 collectable pointer + ; openSSL increments reference counter for X509 returned + by SSL_get_peer_certificate(), but does not increment it + for SSL_get_certificate(). Unnecessary freeing of X509 + pointer caused random GPF later + + * src/rtl/hbsockhb.c + * changed .prg level hb_socketSetBlockingIO() return value + type from lSuccess to nSuccess, to have the same return + value meaning precision as C level function + + * src/rtl/hbsockhb.c + * include/harbour.hbx + + hb_socketGetFD( hSocket ) --> nFD + 2012-01-11 14:47 UTC+0100 Viktor Szakats (harbour syenar.net) * tests/testdyn.prg ! fixed typo discovered by Alex Strickland. Thank you. diff --git a/harbour/contrib/hbcairo/core.c b/harbour/contrib/hbcairo/core.c index e3c7dbd978..936c993d52 100644 --- a/harbour/contrib/hbcairo/core.c +++ b/harbour/contrib/hbcairo/core.c @@ -304,7 +304,7 @@ HB_FUNC( CAIRO_PATH_ITERATOR_CREATE ) if( ppPath && *ppPath ) { - PHB_CAIRO_PATH_ITERATOR pIterator = ( PHB_CAIRO_PATH_ITERATOR ) hb_gcAllocate( sizeof( PHB_CAIRO_PATH_ITERATOR ), &s_gcIteratorFuncs ); + PHB_CAIRO_PATH_ITERATOR pIterator = ( PHB_CAIRO_PATH_ITERATOR ) hb_gcAllocate( sizeof( HB_CAIRO_PATH_ITERATOR ), &s_gcIteratorFuncs ); pIterator->ppPath = ppPath; hb_gcRefInc( ppPath ); pIterator->iPos = -1; diff --git a/harbour/contrib/hbssl/hbssl.h b/harbour/contrib/hbssl/hbssl.h index 51fec1232b..4a62a20dbb 100644 --- a/harbour/contrib/hbssl/hbssl.h +++ b/harbour/contrib/hbssl/hbssl.h @@ -89,7 +89,7 @@ extern SSL_SESSION * hb_SSL_SESSION_par( int iParam ); extern void * hb_X509_is( int iParam ); extern X509 * hb_X509_par( int iParam ); -extern void hb_X509_ret( X509 * x509 ); +extern void hb_X509_ret( X509 * x509, HB_BOOL fRelease ); extern int hb_EVP_MD_is( int iParam ); extern const EVP_MD * hb_EVP_MD_par( int iParam ); diff --git a/harbour/contrib/hbssl/ssl.c b/harbour/contrib/hbssl/ssl.c index 27e5032c56..5893d208ee 100644 --- a/harbour/contrib/hbssl/ssl.c +++ b/harbour/contrib/hbssl/ssl.c @@ -1254,7 +1254,7 @@ HB_FUNC( SSL_GET_MODE ) SSL * ssl = hb_SSL_par( 1 ); if( ssl ) - hb_parnl( SSL_get_mode( ssl ) ); + hb_retnl( SSL_get_mode( ssl ) ); } else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); @@ -1282,7 +1282,7 @@ HB_FUNC( SSL_GET_CERTIFICATE ) SSL * ssl = hb_SSL_par( 1 ); if( ssl ) - hb_X509_ret( SSL_get_certificate( ssl ) ); + hb_X509_ret( SSL_get_certificate( ssl ), HB_FALSE ); } else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); @@ -1295,7 +1295,7 @@ HB_FUNC( SSL_GET_PEER_CERTIFICATE ) SSL * ssl = hb_SSL_par( 1 ); if( ssl ) - hb_X509_ret( SSL_get_peer_certificate( ssl ) ); + hb_X509_ret( SSL_get_peer_certificate( ssl ), HB_TRUE ); } else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); diff --git a/harbour/contrib/hbssl/x509.c b/harbour/contrib/hbssl/x509.c index 7c532007e8..60f398b6e1 100644 --- a/harbour/contrib/hbssl/x509.c +++ b/harbour/contrib/hbssl/x509.c @@ -60,18 +60,25 @@ #include "hbssl.h" +typedef struct +{ + X509 * pX509; + HB_BOOL fRelease; +} HB_X509, * PHB_X509; + static HB_GARBAGE_FUNC( X509_release ) { - void ** ph = ( void ** ) Cargo; + PHB_X509 ph = ( PHB_X509 ) Cargo; /* Check if pointer is not NULL to avoid multiple freeing */ - if( ph && * ph ) + if( ph && ph->pX509 ) { /* Destroy the object */ - X509_free( ( X509 * ) * ph ); + if( ph->fRelease ) + X509_free( ( X509 * ) ph->pX509 ); /* set pointer to NULL just in case */ - * ph = NULL; + ph->pX509 = NULL; } } @@ -88,18 +95,19 @@ void * hb_X509_is( int iParam ) X509 * hb_X509_par( int iParam ) { - void ** ph = ( void ** ) hb_parptrGC( &s_gcX509_funcs, iParam ); + PHB_X509 ph = ( PHB_X509 ) hb_parptrGC( &s_gcX509_funcs, iParam ); - return ph ? ( X509 * ) * ph : NULL; + return ph ? ph->pX509 : NULL; } -void hb_X509_ret( X509 * x509 ) +void hb_X509_ret( X509 * x509, HB_BOOL fRelease ) { - void ** ph = ( void ** ) hb_gcAllocate( sizeof( X509 * ), &s_gcX509_funcs ); + PHB_X509 ph = ( PHB_X509 ) hb_gcAllocate( sizeof( HB_X509 ), &s_gcX509_funcs ); - * ph = ( void * ) x509; + ph->pX509 = x509; + ph->fRelease = fRelease; - hb_retptrGC( ph ); + hb_retptrGC( ( void * ) ph ); } HB_FUNC( X509_GET_SUBJECT_NAME ) diff --git a/harbour/include/harbour.hbx b/harbour/include/harbour.hbx index aad9aba1b5..cb1eaea9d5 100644 --- a/harbour/include/harbour.hbx +++ b/harbour/include/harbour.hbx @@ -743,6 +743,7 @@ DYNAMIC HB_SOCKETCLOSE DYNAMIC HB_SOCKETCONNECT DYNAMIC HB_SOCKETERRORSTRING DYNAMIC HB_SOCKETGETERROR +DYNAMIC HB_SOCKETGETFD DYNAMIC HB_SOCKETGETHOSTNAME DYNAMIC HB_SOCKETGETHOSTS DYNAMIC HB_SOCKETGETIFACES diff --git a/harbour/src/rtl/hbsockhb.c b/harbour/src/rtl/hbsockhb.c index 9e8d1a7a80..bec1cc8da7 100644 --- a/harbour/src/rtl/hbsockhb.c +++ b/harbour/src/rtl/hbsockhb.c @@ -67,7 +67,7 @@ * HB_SOCKETSENDTO( hSocket, cBuffer, [ nLen = LEN( cBuffer ) ], [ nFlags = 0 ], aAddr, [ nTimeout = FOREVER ] ) --> nBytesSent * HB_SOCKETRECV( hSocket, @cBuffer, [ nLen = LEN( cBuffer ) ], [ nFlags = 0 ], [ nTimeout = FOREVER ] ) --> nBytesRecv * HB_SOCKETRECVFROM( hSocket, @cBuffer, [ nLen = LEN( cBuffer ) ], [ nFlags = 0 ], @aAddr, [ nTimeout = FOREVER ] ) --> nBytesRecv - * HB_SOCKETSETBLOCKINGIO( hSocket, lValue ) --> lSuccess + * HB_SOCKETSETBLOCKINGIO( hSocket, lValue ) --> nSuccess * HB_SOCKETSETNODELAY( hSocket, lValue ) --> lSuccess * HB_SOCKETSETEXCLUSIVEADDR( hSocket, lValue ) --> lSuccess * HB_SOCKETSETREUSEADDR( hSocket, lValue ) --> lSuccess @@ -87,6 +87,7 @@ * HB_SOCKETGETHOSTNAME( aAddr ) --> cHostName * HB_SOCKETGETHOSTS( cAddr, [ nFamily = HB_SOCKET_AF_INET ] ) --> aHosts * HB_SOCKETGETIFACES( [ nFamily ], [ lNoAliases ] ) --> aIfaces + * HB_SOCKETGETFD( hSocket ) --> nFD */ #include "hbapiitm.h" @@ -468,7 +469,7 @@ HB_FUNC( HB_SOCKETSETBLOCKINGIO ) HB_SOCKET socket = hb_socketParam( 1 ); if( socket != HB_NO_SOCKET ) { - hb_retl( hb_socketSetBlockingIO( socket, hb_parl( 2 ) ) == 0 ); + hb_retni( hb_socketSetBlockingIO( socket, hb_parl( 2 ) ) ); } } @@ -704,3 +705,8 @@ HB_FUNC( HB_SOCKETGETIFACES ) else hb_reta( 0 ); } + +HB_FUNC( HB_SOCKETGETFD ) +{ + hb_retni( hb_socketParam( 1 ) ); +}