]> granicus.if.org Git - php/commitdiff
fix 64-bit integer overflow in mhash_keygen_s2k
authorStanislav Malyshev <stas@php.net>
Tue, 20 Apr 2010 00:45:07 +0000 (00:45 +0000)
committerStanislav Malyshev <stas@php.net>
Tue, 20 Apr 2010 00:45:07 +0000 (00:45 +0000)
ext/hash/hash.c

index 0eb0c7c95672b1265aae1323ed8b9e18c45c5143..4c1222f0017e0a85b2d0be702423335de68236d3 100644 (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;