From 8bae6cb2b9586d47d32483f12b8511f062b011ad Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Fri, 18 Jan 2008 00:17:35 +0000 Subject: [PATCH] 2008-01-18 01:17 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbzlib/zip.c * harbour/contrib/hbzlib/unzip.c ! fixed possible access to uninitialized memory - thanks to Lorenzo * harbour/contrib/hbzlib/hbzlib.c * fixed casting - thanks to Andi * harbour/contrib/hbzlib/hbmzip.c * use hb_fsGetOsHandle() instead of LongToHandle() - code which uses hb_fsGetOsHandle() will work also with our own virtual handles if we add such extensions in the future * harbour/source/vm/harbinit.prg ! call __SetHelpK() only when HELP() function/procedure exist Clipper compatible behavior --- harbour/ChangeLog | 17 +++++++++++++++++ harbour/contrib/hbzlib/hbmzip.c | 4 ++-- harbour/contrib/hbzlib/hbzlib.c | 9 +++++---- harbour/contrib/hbzlib/unzip.c | 4 ++-- harbour/contrib/hbzlib/zip.c | 4 ++-- harbour/source/vm/harbinit.prg | 4 +++- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8f3619b826..fbb2ab8f54 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,23 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2008-01-18 01:17 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/hbzlib/zip.c + * harbour/contrib/hbzlib/unzip.c + ! fixed possible access to uninitialized memory - thanks to Lorenzo + + * harbour/contrib/hbzlib/hbzlib.c + * fixed casting - thanks to Andi + + * harbour/contrib/hbzlib/hbmzip.c + * use hb_fsGetOsHandle() instead of LongToHandle() - code which + uses hb_fsGetOsHandle() will work also with our own virtual + handles if we add such extensions in the future + + * harbour/source/vm/harbinit.prg + ! call __SetHelpK() only when HELP() function/procedure exist + Clipper compatible behavior + 2008-01-17 17:29 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/harbour.spec ! removed dummy %endif which left after recent modification diff --git a/harbour/contrib/hbzlib/hbmzip.c b/harbour/contrib/hbzlib/hbmzip.c index 853ff477fb..215513bedd 100644 --- a/harbour/contrib/hbzlib/hbmzip.c +++ b/harbour/contrib/hbzlib/hbmzip.c @@ -577,7 +577,7 @@ static int hb_zipStoreFile( zipFile hZip, char* szFileName, char* szName ) FILETIME ftutc, ft; SYSTEMTIME st; - if( GetFileTime( LongToHandle( hFile ), NULL, NULL, &ftutc ) && + if( GetFileTime( hb_fsGetOsHandle( hFile ), NULL, NULL, &ftutc ) && FileTimeToLocalFileTime( &ftutc, &ft ) & FileTimeToSystemTime( &ft, &st ) ) { @@ -711,7 +711,7 @@ static int hb_unzipExtractCurrentFile( unzFile hUnzip, char* szFileName ) if( SystemTimeToFileTime( &st, &ft ) && LocalFileTimeToFileTime( &ft, &ftutc ) ) { - SetFileTime( LongToHandle( hFile ), &ftutc, &ftutc, &ftutc ); + SetFileTime( hb_fsGetOsHandle( hFile ), &ftutc, &ftutc, &ftutc ); } } #endif diff --git a/harbour/contrib/hbzlib/hbzlib.c b/harbour/contrib/hbzlib/hbzlib.c index 36a5dc60f5..9c116718ef 100644 --- a/harbour/contrib/hbzlib/hbzlib.c +++ b/harbour/contrib/hbzlib/hbzlib.c @@ -107,7 +107,7 @@ HB_FUNC( HB_COMPRESSBOUND ) if( ISCHAR( 1 ) ) hb_retnint( compressBound( hb_parclen( 1 ) ) ); else if( ISNUM( 1 ) ) - hb_retnint( compressBound( hb_parnint( 1 ) ) ); + hb_retnint( compressBound( ( uLong ) hb_parnint( 1 ) ) ); else hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, &hb_errFuncName, HB_ERR_ARGS_BASEPARAMS ); } @@ -148,7 +148,8 @@ HB_FUNC( HB_COMPRESS ) } else { - ulDstLen = ISNUM( 2 ) ? hb_parnint( 2 ) : compressBound( ulLen ); + ulDstLen = ISNUM( 2 ) ? ( uLong ) hb_parnint( 2 ) : + compressBound( ulLen ); pDest = ( char * ) hb_xalloc( ulDstLen + 1 ); } @@ -211,7 +212,7 @@ HB_FUNC( HB_UNCOMPRESS ) } else { - ulDstLen = ISNUM( 2 ) ? hb_parnint( 2 ) : + ulDstLen = ISNUM( 2 ) ? ( uLong ) hb_parnint( 2 ) : hb_zlibUncompressedSize( szData, ulLen ); pDest = ( char * ) hb_xalloc( ulDstLen + 1 ); } @@ -466,7 +467,7 @@ HB_FUNC( HB_GZSEEK ) { gzFile gz = hb_gzParam( 1 ); if( gz ) - hb_retnint( gzseek( gz, hb_parnint( 2 ), ISNUM( 3 ) ? + hb_retnint( gzseek( gz, ( z_off_t ) hb_parnint( 2 ), ISNUM( 3 ) ? hb_parni( 3 ) : SEEK_SET ) ); } else diff --git a/harbour/contrib/hbzlib/unzip.c b/harbour/contrib/hbzlib/unzip.c index 779eaa6822..a370f7926c 100644 --- a/harbour/contrib/hbzlib/unzip.c +++ b/harbour/contrib/hbzlib/unzip.c @@ -210,7 +210,7 @@ local int unzlocal_getShort ( uLong *pX) { uLong x ; - int i; + int i = 0; int err; err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); @@ -238,7 +238,7 @@ local int unzlocal_getLong ( uLong *pX) { uLong x ; - int i; + int i = 0; int err; err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); diff --git a/harbour/contrib/hbzlib/zip.c b/harbour/contrib/hbzlib/zip.c index 425568f03f..8f670164fd 100644 --- a/harbour/contrib/hbzlib/zip.c +++ b/harbour/contrib/hbzlib/zip.c @@ -383,7 +383,7 @@ local int ziplocal_getShort ( uLong *pX) { uLong x ; - int i; + int i = 0; int err; err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); @@ -411,7 +411,7 @@ local int ziplocal_getLong ( uLong *pX) { uLong x ; - int i; + int i = 0; int err; err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); diff --git a/harbour/source/vm/harbinit.prg b/harbour/source/vm/harbinit.prg index 2bdc5e24c4..2a925e120e 100644 --- a/harbour/source/vm/harbinit.prg +++ b/harbour/source/vm/harbinit.prg @@ -82,7 +82,9 @@ PROCEDURE ClipInit /* TOFIX: In Clipper this function is not called from here CLIPINIT(). */ /* NOTE: In Clipper __SETHELPK() is called *after* ERRORSYS(). */ - __SetHelpK() + IF Type( "HELP()" ) == "UI" + __SetHelpK() + ENDIF RETURN