2009-07-23 21:44 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* contrib/rddads/ads1.c
    ! Reverted prev change plus added error handling. Thx Przemek.

  * contrib/hbssl/evpciph.c
  * contrib/hbssl/ssl.c
  * contrib/hbssl/evpmd.c
  * contrib/hbssl/evpenc.c
  * contrib/hbssl/evppkey.c
  * contrib/hbssl/evp.c
  * contrib/hbssl/tests/crypt.prg
    * Minor improvements.
    % Deleted unnecessary ( void * ) casts.
    ! Fixed leaks (using valgrind and crypt.prg).
      There is still one reported, but can't find the reason.

  * contrib/hbcurl/hbcurl.c
    % Deleted unnecessary ( void * ) casts.
This commit is contained in:
Viktor Szakats
2009-07-23 19:46:11 +00:00
parent 0a95b29d0f
commit 46c0860b3b
10 changed files with 128 additions and 22 deletions

View File

@@ -17,6 +17,25 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-07-23 21:44 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/rddads/ads1.c
! Reverted prev change plus added error handling. Thx Przemek.
* contrib/hbssl/evpciph.c
* contrib/hbssl/ssl.c
* contrib/hbssl/evpmd.c
* contrib/hbssl/evpenc.c
* contrib/hbssl/evppkey.c
* contrib/hbssl/evp.c
* contrib/hbssl/tests/crypt.prg
* Minor improvements.
% Deleted unnecessary ( void * ) casts.
! Fixed leaks (using valgrind and crypt.prg).
There is still one reported, but can't find the reason.
* contrib/hbcurl/hbcurl.c
% Deleted unnecessary ( void * ) casts.
2009-07-23 20:18 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/rddads/ads1.c
! Fixed buffer size in one place related to MEMO field handling.

View File

@@ -524,7 +524,7 @@ static void PHB_CURL_ret( PHB_CURL from )
{
void ** ph = ( void ** ) hb_gcAlloc( sizeof( PHB_CURL ), PHB_CURL_release );
* ph = ( void * ) PHB_CURL_create( from );
* ph = PHB_CURL_create( from );
hb_retptrGC( ph );
}

View File

@@ -83,6 +83,16 @@ HB_FUNC( ERR_LOAD_EVP_STRINGS )
ERR_load_EVP_strings();
}
HB_FUNC( EVP_PKEY_FREE )
{
EVP_PKEY * key = ( EVP_PKEY * ) hb_parptr( 1 );
if( key )
EVP_PKEY_free( key );
else
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
HB_FUNC( EVP_BYTESTOKEY )
{
const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 1 );

View File

@@ -70,6 +70,8 @@ static HB_GARBAGE_FUNC( EVP_CIPHER_CTX_release )
/* Check if pointer is not NULL to avoid multiple freeing */
if( ph && * ph )
{
/* Cleanup the object */
EVP_CIPHER_CTX_cleanup( ( EVP_CIPHER_CTX * ) * ph );
/* Destroy the object */
hb_xfree( * ph );
@@ -428,7 +430,9 @@ HB_FUNC( HB_EVP_CIPHER_CTX_CREATE )
EVP_CIPHER_CTX * ctx = ( EVP_CIPHER_CTX * ) hb_xgrab( sizeof( EVP_CIPHER_CTX ) );
* ph = ( void * ) ctx;
EVP_CIPHER_CTX_init( ctx );
* ph = ctx;
hb_retptrGC( ph );
}
@@ -587,7 +591,10 @@ HB_FUNC( EVP_ENCRYPTUPDATE )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -613,7 +620,10 @@ HB_FUNC( EVP_ENCRYPTFINAL )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -639,7 +649,10 @@ HB_FUNC( EVP_ENCRYPTFINAL_EX )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -706,7 +719,10 @@ HB_FUNC( EVP_DECRYPTUPDATE )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -732,7 +748,10 @@ HB_FUNC( EVP_DECRYPTFINAL )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -758,7 +777,10 @@ HB_FUNC( EVP_DECRYPTFINAL_EX )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -827,7 +849,10 @@ HB_FUNC( EVP_CIPHERUPDATE )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -853,7 +878,10 @@ HB_FUNC( EVP_CIPHERFINAL )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -879,7 +907,10 @@ HB_FUNC( EVP_CIPHERFINAL_EX )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -951,6 +982,7 @@ HB_FUNC( EVP_SEALINIT )
hb_xfree( ek );
hb_xfree( ekl );
hb_xfree( pubk );
}
}
}
@@ -981,7 +1013,10 @@ HB_FUNC( EVP_SEALUPDATE )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -1007,7 +1042,10 @@ HB_FUNC( EVP_SEALFINAL )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -1058,7 +1096,10 @@ HB_FUNC( EVP_OPENUPDATE )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -1084,7 +1125,10 @@ HB_FUNC( EVP_OPENFINAL )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else

View File

@@ -91,7 +91,7 @@ HB_FUNC( HB_EVP_ENCODE_CTX_CREATE )
EVP_ENCODE_CTX * ctx = ( EVP_ENCODE_CTX * ) hb_xgrab( sizeof( EVP_ENCODE_CTX ) );
* ph = ( void * ) ctx;
* ph = ctx;
hb_retptrGC( ph );
}
@@ -132,7 +132,10 @@ HB_FUNC( EVP_ENCODEUPDATE )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -158,7 +161,10 @@ HB_FUNC( EVP_ENCODEFINAL )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -201,7 +207,10 @@ HB_FUNC( EVP_DECODEUPDATE )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -227,7 +236,10 @@ HB_FUNC( EVP_DECODEFINAL )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else

View File

@@ -244,7 +244,7 @@ HB_FUNC( EVP_MD_CTX_CREATE )
EVP_MD_CTX * ctx = EVP_MD_CTX_create();
* ph = ( void * ) ctx;
* ph = ctx;
hb_retptrGC( ph );
}
@@ -378,7 +378,10 @@ HB_FUNC( EVP_DIGESTFINAL )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -404,7 +407,10 @@ HB_FUNC( EVP_DIGESTFINAL_EX )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else
@@ -473,7 +479,10 @@ HB_FUNC( EVP_SIGNFINAL )
hb_xfree( buffer );
}
else
{
hb_xfree( buffer );
hb_storc( NULL, 2 );
}
}
}
else

View File

@@ -93,7 +93,7 @@ HB_FUNC( EVP_PKEY_NEW )
EVP_PKEY * ctx = EVP_PKEY_new();
* ph = ( void * ) ctx;
* ph = ctx;
hb_retptrGC( ph );
}

View File

@@ -128,7 +128,7 @@ HB_FUNC( SSL_NEW )
SSL * ssl = SSL_new( ctx );
* ph = ( void * ) ssl;
* ph = ssl;
hb_retptrGC( ph );
}
@@ -149,7 +149,7 @@ HB_FUNC( SSL_DUP )
SSL * ssl = SSL_dup( ssl_par );
* ph = ( void * ) ssl;
* ph = ssl;
hb_retptrGC( ph );
}

View File

@@ -20,7 +20,9 @@ PROCEDURE Main()
LOCAL cKey := "key"
LOCAL a, iv, pub, bioe, tmp
LOCAL a, iv, pub
LOCAL bioe
LOCAL tmp
LOCAL all := {;
@PEM_READ_BIO_PRIVATEKEY() ,;
@@ -56,8 +58,7 @@ PROCEDURE Main()
? "ENCRYTPTED", ">" + hb_StrToHex( encrypted ) + "<"
? ">" + encrypted + "<"
EVP_CIPHER_CTX_init( ctx )
EVP_CIPHER_CTX_cleanup( ctx )
ctx := hb_EVP_CIPHER_CTX_create()
EVP_DecryptInit( ctx, "AES-192-OFB", cKey )
@@ -72,15 +73,18 @@ PROCEDURE Main()
? ERR_load_PEM_strings()
? OpenSSL_add_all_algorithms()
EVP_CIPHER_CTX_init( ctx )
EVP_CIPHER_CTX_cleanup( ctx )
ctx := hb_EVP_CIPHER_CTX_create()
? "()()()()()()()"
// bioe := BIO_new_fd( 1, HB_BIO_NOCLOSE )
// FOR EACH tmp IN all
// ? tmp:__enumIndex(), tmp:exec( "pubkey.pem", "test" )
// ? ; ERR_print_errors( bioe )
// NEXT
? "=============="
bioe := BIO_new_fd( 1, HB_BIO_NOCLOSE )
FOR EACH tmp IN all
? tmp:__enumIndex(), pub := tmp:exec( "pubkey.pem", "test" )
IF ! Empty( pub )
? "EVP_PKEY_free", EVP_PKEY_free( pub )
ENDIF
? ; ERR_print_errors( bioe )
NEXT
BIO_free( bioe )
? pub := PEM_READ_BIO_PUBKEY( "pubkey.pem", "test" )
@@ -89,7 +93,9 @@ PROCEDURE Main()
? ValType( a[ 1 ] ), ">" + hb_StrToHex( a[ 1 ] ) + "<"
? ValType( iv ), ">" + hb_StrToHex( iv ) + "<"
// BIO_free( bioe )
? "EVP_PKEY_free", EVP_PKEY_free( pub )
ctx := NIL
EVP_cleanup()

View File

@@ -2244,9 +2244,15 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
else
{
u32Len++; /* make room for NULL */
pucBuf = ( UNSIGNED8 * ) hb_xgrab( u32Len + 1 );
AdsGetBinary( pArea->hTable, ADSFIELD( uiIndex ), 0, pucBuf, &u32Len );
hb_itemPutCLPtr( pItem, ( char * ) pucBuf, u32Len );
pucBuf = ( UNSIGNED8 * ) hb_xgrab( u32Len );
ulRetVal = AdsGetBinary( pArea->hTable, ADSFIELD( uiIndex ), 0, pucBuf, &u32Len );
if( ulRetVal != AE_SUCCESS )
{
hb_xfree( pucBuf );
hb_itemPutC( pItem, NULL );
}
else
hb_itemPutCLPtr( pItem, ( char * ) pucBuf, u32Len );
}
}
hb_itemSetCMemo( pItem );