fix 64-bit integer overflow in mhash_keygen_s2k

This commit is contained in:
Stanislav Malyshev 2010-04-20 00:45:07 +00:00
parent 213436c3fb
commit 129019b9fc

View file

@ -744,15 +744,17 @@ PHP_FUNCTION(mhash_get_block_size)
Generates a key using hash functions */
PHP_FUNCTION(mhash_keygen_s2k)
{
long algorithm, bytes;
long algorithm, l_bytes;
int bytes;
char *password, *salt;
int password_len, salt_len;
char padded_salt[SALT_SIZE];
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lssl", &algorithm, &password, &password_len, &salt, &salt_len, &bytes) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lssl", &algorithm, &password, &password_len, &salt, &salt_len, &l_bytes) == FAILURE) {
return;
}
bytes = (int)l_bytes;
if (bytes <= 0){
php_error_docref(NULL TSRMLS_CC, E_WARNING, "the byte parameter must be greater than 0");
RETURN_FALSE;