From 3aea6dfbdcb293137d4b84bec92a52b50f724e0f Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 11 Feb 2011 18:24:49 +0000 Subject: [PATCH] 2011-02-11 19:24 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/base64d.c ! Fixed TOFIX to handle too large result. Now it will RTE. Please check me. * src/rtl/hbrandom.c * Formatting. * src/rtl/space.c * Fixed commented call. --- harbour/ChangeLog | 11 +++++++++++ harbour/src/rtl/base64d.c | 19 ++++++++++++++----- harbour/src/rtl/hbrandom.c | 4 ++-- harbour/src/rtl/space.c | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index daeb8f775f..948e7ca69f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,17 @@ The license applies to all entries newer than 2009-04-28. */ +2011-02-11 19:24 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/base64d.c + ! Fixed TOFIX to handle too large result. Now it will RTE. + Please check me. + + * src/rtl/hbrandom.c + * Formatting. + + * src/rtl/space.c + * Fixed commented call. + 2011-02-11 15:45 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbqt/qtcore/hbqt_pointer.cpp * contrib/hbqt/qtcore/hbqt.h diff --git a/harbour/src/rtl/base64d.c b/harbour/src/rtl/base64d.c index 6ce96e2027..eebc15e6da 100644 --- a/harbour/src/rtl/base64d.c +++ b/harbour/src/rtl/base64d.c @@ -54,6 +54,7 @@ */ #include "hbapi.h" +#include "hbapierr.h" /* Warning: this code works only on ASCII based machines */ @@ -125,14 +126,22 @@ static HB_SIZE base64_decode_block( const char * code_in, const HB_SIZE length_i HB_FUNC( HB_BASE64DECODE ) { - HB_SIZE len = hb_parclen( 1 ); + HB_SIZE nSrcLen = hb_parclen( 1 ); - if( len > 0 && len <= INT_MAX ) /* TOFIX */ + if( nSrcLen > 0 ) { - char * code = ( char * ) hb_xgrab( ( ( ( len * 3 ) / 4 ) + 1 ) * sizeof( char ) ); - HB_SIZE nSize = base64_decode_block( hb_parcx( 1 ), len, code ); + HB_SIZE nDstLen = ( ( ( nSrcLen * 3 ) / 4 ) + 1 ); - hb_retclen_buffer( code, nSize ); + if( nDstLen <= HB_SIZE_MAX ) + { + char * code = ( char * ) hb_xgrab( nDstLen * sizeof( char ) ); + + nDstLen = base64_decode_block( hb_parcx( 1 ), nSrcLen, code ); + + hb_retclen_buffer( code, nDstLen ); + } + else + hb_errRT_BASE( EG_STROVERFLOW, 9999, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } else hb_retc_null(); diff --git a/harbour/src/rtl/hbrandom.c b/harbour/src/rtl/hbrandom.c index 7a0d41fa98..e3e5ab811d 100644 --- a/harbour/src/rtl/hbrandom.c +++ b/harbour/src/rtl/hbrandom.c @@ -66,7 +66,7 @@ static volatile int s_fInit = 0; * * HB_RANDOM() --> returns a real value n so that 0 <= n < 1 * HB_RANDOM( x ) --> returns a real number n so that 0 <= n < x - * HB_RANDOM( x, y) --> Returns a real number n so that x <= n < y + * HB_RANDOM( x, y ) --> Returns a real number n so that x <= n < y */ HB_FUNC( HB_RANDOM ) { @@ -95,7 +95,7 @@ HB_FUNC( HB_RANDOM ) * * HB_RANDOMINT() --> returns 0 or 1, evenly distributed * HB_RANDOMINT( N ) --> returns an integer between 1 and N (inclusive) - * HB_RANDOMINT( x, y) --> Returns a real number between x and y (inclusive) + * HB_RANDOMINT( x, y ) --> Returns a real number between x and y (inclusive) * The integer returned is of the longest type available */ HB_FUNC( HB_RANDOMINT ) diff --git a/harbour/src/rtl/space.c b/harbour/src/rtl/space.c index 820dba7ddb..307733bdfd 100644 --- a/harbour/src/rtl/space.c +++ b/harbour/src/rtl/space.c @@ -71,7 +71,7 @@ HB_FUNC( SPACE ) /* NOTE: String overflow could never occure since a string can be as large as ULONG_MAX, and the maximum length that can be specified is LONG_MAX here. [vszakats] */ - /* hb_errRT_BASE( EG_STROVERFLOW, 1233, NULL, HB_ERR_FUNCNAME ); */ + /* hb_errRT_BASE( EG_STROVERFLOW, 1233, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); */ hb_xmemset( szResult, ' ', nLen ); hb_retclen_buffer( szResult, nLen );