From fec60ddb225aa03ebaefda3c0c33e23427c0aab1 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 18 Oct 2008 20:03:36 +0000 Subject: [PATCH] 2008-10-18 22:03 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * contrib/xhb/hbcrypt.c ! Fixed lower level crypt functions to not do zero division on zero length key input. --- harbour/ChangeLog | 5 +++++ harbour/contrib/xhb/hbcrypt.c | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 67a8c1581a..304befb99f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,11 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-10-18 22:03 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * contrib/xhb/hbcrypt.c + ! Fixed lower level crypt functions to not do + zero division on zero length key input. + 2008-10-18 21:16 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * source/common/hbgete.c ! Fixed recent warning on Win32 platforms. diff --git a/harbour/contrib/xhb/hbcrypt.c b/harbour/contrib/xhb/hbcrypt.c index 3ce863d917..1f40110af8 100644 --- a/harbour/contrib/xhb/hbcrypt.c +++ b/harbour/contrib/xhb/hbcrypt.c @@ -85,7 +85,7 @@ void nxs_crypt( BYTE *cipher ) { - if(keylen > NXS_MAX_KEYLEN ) + if( keylen > NXS_MAX_KEYLEN ) { keylen = NXS_MAX_KEYLEN; } @@ -112,7 +112,7 @@ void nxs_decrypt( const unsigned char *key, ULONG keylen, BYTE *result ) { - if(keylen > NXS_MAX_KEYLEN ) + if( keylen > NXS_MAX_KEYLEN ) { keylen = NXS_MAX_KEYLEN; } @@ -154,7 +154,8 @@ void nxs_scramble( nxs_make_scramble( scramble, key, keylen ); /* Leave alone the last block */ - len = (srclen / keylen) * keylen; + if( keylen > 0 ) + len = (srclen / keylen) * keylen; nxs_partial_scramble( source, cipher, scramble, len, keylen ); keylen = srclen - len; @@ -207,7 +208,8 @@ void nxs_unscramble( nxs_make_scramble( scramble, key, keylen ); /* Leave alone the last block */ - len = (cipherlen / keylen) * keylen; + if( keylen > 0 ) + len = (cipherlen / keylen) * keylen; nxs_partial_unscramble( cipher, scramble, len , keylen ); keylen = cipherlen - len;