2011-02-11 13:30 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* src/rtl/base64d.c
! Fixed crash when empty or non-string parameter was passed to HB_BASE64DECODE().
+ tests/base64.prg
+ Added base64 test suite. [Tamas]
This commit is contained in:
@@ -16,6 +16,13 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2011-02-11 13:30 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* src/rtl/base64d.c
|
||||
! Fixed crash when empty or non-string parameter was passed to HB_BASE64DECODE().
|
||||
|
||||
+ tests/base64.prg
|
||||
+ Added base64 test suite. [Tamas]
|
||||
|
||||
2011-02-11 12:21 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* utils/hbmk2/hbmk2.prg
|
||||
! Fixed regression in 2011-02-10 23:45 UTC+0100 Viktor Szakats,
|
||||
|
||||
@@ -165,7 +165,7 @@ HB_FUNC( HB_BASE64DECODE )
|
||||
{
|
||||
HB_SIZE len = hb_parclen( 1 );
|
||||
|
||||
if( len <= INT_MAX ) /* TOFIX */
|
||||
if( len > 0 && len <= INT_MAX ) /* TOFIX */
|
||||
{
|
||||
char * code = ( char * ) hb_xgrab( ( ( ( ( len - 1 ) * 3 ) / 4 ) + 1 ) * sizeof( char ) );
|
||||
HB_SIZE nSize = base64_decode_block( hb_parcx( 1 ), len, code );
|
||||
|
||||
46
harbour/tests/base64.prg
Normal file
46
harbour/tests/base64.prg
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/* RFC4648 test vectors for base64 */
|
||||
|
||||
#pragma warninglevel=3
|
||||
#pragma exitseverity=2
|
||||
|
||||
REQUEST HB_GT_CGI_DEFAULT
|
||||
|
||||
PROCEDURE Main()
|
||||
|
||||
LOCAL aTestVectors, aVector, cStr
|
||||
|
||||
aTestVectors := { ;
|
||||
"" => "", ;
|
||||
"f" => "Zg==", ;
|
||||
"fo" => "Zm8=", ;
|
||||
"foo" => "Zm9v", ;
|
||||
"foob" => "Zm9vYg==", ;
|
||||
"fooba" => "Zm9vYmE=", ;
|
||||
"foobar" => "Zm9vYmFy" }
|
||||
|
||||
FOR EACH aVector IN aTestVectors
|
||||
|
||||
cStr := hb_base64encode( aVector:__enumKey )
|
||||
IF cStr != aVector
|
||||
OutStd( hb_strFormat( "hb_base64encode(): expected '%s' got '%s' while encoding '%s'" + hb_eol(), ;
|
||||
aVector:__enumKey(), cStr, aVector ) )
|
||||
ELSE
|
||||
OutStd( hb_strFormat( "hb_base64encode(): passed '%s'" + hb_eol(), aVector:__enumKey ) )
|
||||
ENDIF
|
||||
|
||||
cStr := hb_base64decode( aVector )
|
||||
IF cStr != aVector:__enumKey()
|
||||
OutStd( hb_strFormat( "hb_base64decode(): expected '%s' got '%s' while decoding '%s'" + hb_eol(), ;
|
||||
aVector, cStr, aVector:__enumKey() ) )
|
||||
ELSE
|
||||
OutStd( hb_strFormat( "hb_base64decode(): passed '%s'" + hb_eol(), aVector ) )
|
||||
ENDIF
|
||||
NEXT
|
||||
|
||||
RETURN
|
||||
|
||||
|
||||
Reference in New Issue
Block a user