cvs: php4 /ext/mhash mhash.c
| From: | Sascha Schumann | Date: | Sun, 01 Jul 2001 11:20:57 +0000 |
| Subject: | cvs: php4 /ext/mhash mhash.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-6055@lists.php.net to get a copy of this message | ||
sas Sun Jul 1 07:20:57 2001 EDT
Modified files:
/php4/ext/mhash mhash.c
Log:
mhash_keygen_s2k() overwrote the limits of a statically allocated buffer
for long salts. We truncate the salt now appropiately.
PR: #11817
Index: php4/ext/mhash/mhash.c
diff -u php4/ext/mhash/mhash.c:1.28 php4/ext/mhash/mhash.c:1.29
--- php4/ext/mhash/mhash.c:1.28 Wed Jun 6 09:05:46 2001
+++ php4/ext/mhash/mhash.c Sun Jul 1 07:20:56 2001
@@ -225,7 +225,7 @@
password = Z_STRVAL_PP(input_password);
password_len = Z_STRLEN_PP(input_password);
- salt_len = Z_STRLEN_PP(input_salt);
+ salt_len = MIN(Z_STRLEN_PP(input_salt), SALT_SIZE);
if (salt_len > mhash_get_keygen_salt_size(KEYGEN_S2K_SALTED)) {
sprintf( error, "The specified salt [%d] is more bytes than the required by the algorithm
[%d]\n", salt_len, mhash_get_keygen_salt_size(KEYGEN_S2K_SALTED));
@@ -233,8 +233,9 @@
php_error(E_WARNING, error);
}
- memset( salt, 0, SALT_SIZE);
- memcpy( salt, Z_STRVAL_PP(input_salt), salt_len);
+ memcpy(salt, Z_STRVAL_PP(input_salt), salt_len);
+ if (salt_len < SALT_SIZE)
+ memset(salt + salt_len, 0, SALT_SIZE - salt_len);
salt_len=SALT_SIZE;
/* if (salt_len==0) {