com php-src: basic fixes to ext/hash: ext/hash/hash.c ext/hash/hash_haval.c ext/hash/hash_joaat.c ext/has h/hash_md.c ext/hash/hash_ripemd.c
ext/hash/hash_ sha.c ext/hash/php_hash.h ext/hash/php_hash_haval .h ext/hash/php_hash_joaat.h ext/hash/php_hash_ md.h ext/hash/php_hash_ripemd.h
ext/hash/php_hash _sha.h

From: Date: Wed, 27 Nov 2013 09:33:08 +0000
Subject: com php-src: basic fixes to ext/hash: ext/hash/hash.c ext/hash/hash_haval.c ext/hash/hash_joaat.c ext/has h/hash_md.c ext/hash/hash_ripemd.c
ext/hash/hash_ sha.c ext/hash/php_hash.h ext/hash/php_hash_haval .h ext/hash/php_hash_joaat.h ext/hash/php_hash_ md.h ext/hash/php_hash_ripemd.h
ext/hash/php_hash _sha.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-74083@lists.php.net to get a copy of this message
Commit: 81158446748d3153c5defe479b3083601d366d03 Author: Anatol Belski <ab@php.net> Wed, 27 Nov 2013 10:33:08 +0100 Parents: 0336763311e0d4ad44ac47b88f4e39ecd8503247 Branches: str_size_and_int64 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=81158446748d3153c5defe479b3083601d366d03 Log: basic fixes to ext/hash Changed paths: M ext/hash/hash.c M ext/hash/hash_haval.c M ext/hash/hash_joaat.c M ext/hash/hash_md.c M ext/hash/hash_ripemd.c M ext/hash/hash_sha.c M ext/hash/php_hash.h M ext/hash/php_hash_haval.h M ext/hash/php_hash_joaat.h M ext/hash/php_hash_md.h M ext/hash/php_hash_ripemd.h M ext/hash/php_hash_sha.h

diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 87f19c5..b4d48ff 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -86,7 +86,7 @@ static struct mhash_bc_entry mhash_to_hash[MHASH_NUM_ALGOS] = { /* Hash Registry Access */ -PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_len) /* {{{ */ +PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, zend_str_size_int algo_len) /* {{{ */ { php_hash_ops *ops; char *lower = estrndup(algo, algo_len); @@ -103,7 +103,7 @@ PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_l PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops *ops) /* {{{ */ { - int algo_len = strlen(algo); + zend_str_size_int algo_len = strlen(algo); char *lower = estrndup(algo, algo_len); zend_str_tolower(lower, algo_len); @@ -126,13 +126,13 @@ PHP_HASH_API int php_hash_copy(const void *ops, void *orig_context, void *dest_c static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_bool raw_output_default) /* {{{ */ { char *algo, *data, *digest; - int algo_len, data_len; + zend_str_size_int algo_len, data_len; zend_bool raw_output = raw_output_default; const php_hash_ops *ops; void *context; php_stream *stream = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &algo, &algo_len, &data, &data_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|b", &algo, &algo_len, &data, &data_len, &raw_output) == FAILURE) { return; } @@ -203,21 +203,21 @@ PHP_FUNCTION(hash_file) } /* }}} */ -static inline void php_hash_string_xor_char(unsigned char *out, const unsigned char *in, const unsigned char xor_with, const int length) { - int i; +static inline void php_hash_string_xor_char(unsigned char *out, const unsigned char *in, const unsigned char xor_with, const zend_str_size_int length) { + zend_str_size_int i; for (i=0; i < length; i++) { out[i] = in[i] ^ xor_with; } } -static inline void php_hash_string_xor(unsigned char *out, const unsigned char *in, const unsigned char *xor_with, const int length) { - int i; +static inline void php_hash_string_xor(unsigned char *out, const unsigned char *in, const unsigned char *xor_with, const zend_str_size_int length) { + zend_str_size_int i; for (i=0; i < length; i++) { out[i] = in[i] ^ xor_with[i]; } } -static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops *ops, void *context, const unsigned char *key, const int key_len) { +static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops *ops, void *context, const unsigned char *key, const zend_str_size_int key_len) { memset(K, 0, ops->block_size); if (key_len > ops->block_size) { /* Reduce the key first */ @@ -231,7 +231,7 @@ static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops * php_hash_string_xor_char(K, K, 0x36, ops->block_size); } -static inline void php_hash_hmac_round(unsigned char *final, const php_hash_ops *ops, void *context, const unsigned char *key, const unsigned char *data, const long data_size) { +static inline void php_hash_hmac_round(unsigned char *final, const php_hash_ops *ops, void *context, const unsigned char *key, const unsigned char *data, const php_int_t data_size) { ops->hash_init(context); ops->hash_update(context, key, ops->block_size); ops->hash_update(context, data, data_size); @@ -241,13 +241,13 @@ static inline void php_hash_hmac_round(unsigned char *final, const php_hash_ops static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_bool raw_output_default) /* {{{ */ { char *algo, *data, *digest, *key, *K; - int algo_len, data_len, key_len; + zend_str_size_int algo_len, data_len, key_len; zend_bool raw_output = raw_output_default; const php_hash_ops *ops; void *context; php_stream *stream = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|b", &algo, &algo_len, &data, &data_len, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSS|b", &algo, &algo_len, &data, &data_len, &key, &key_len, &raw_output) == FAILURE) { return; } @@ -274,7 +274,7 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename, if (isfilename) { char buf[1024]; - int n; + zend_str_size_int n; ops->hash_init(context); ops->hash_update(context, (unsigned char *) K, ops->block_size); while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) { @@ -333,13 +333,14 @@ Initialize a hashing context */ PHP_FUNCTION(hash_init) { char *algo, *key = NULL; - int algo_len, key_len = 0, argc = ZEND_NUM_ARGS(); - long options = 0; + zend_str_size_int algo_len, key_len = 0; + int argc = ZEND_NUM_ARGS(); + php_int_t options = 0; void *context; const php_hash_ops *ops; php_hash_data *hash; - if (zend_parse_parameters(argc TSRMLS_CC, "s|ls", &algo, &algo_len, &options, &key, &key_len) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "S|iS", &algo, &algo_len, &options, &key, &key_len) == FAILURE) { return; } @@ -400,9 +401,9 @@ PHP_FUNCTION(hash_update) zval *zhash; php_hash_data *hash; char *data; - int data_len; + zend_str_size_int data_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &zhash, &data, &data_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rS", &zhash, &data, &data_len) == FAILURE) { return; } @@ -421,9 +422,9 @@ PHP_FUNCTION(hash_update_stream) zval *zhash, *zstream; php_hash_data *hash; php_stream *stream = NULL; - long length = -1, didread = 0; + php_int_t length = -1, didread = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &zhash, &zstream, &length) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|i", &zhash, &zstream, &length) == FAILURE) { return; } @@ -432,7 +433,8 @@ PHP_FUNCTION(hash_update_stream) while (length) { char buf[1024]; - long n, toread = 1024; + zend_str_size_int n; + php_int_t toread = 1024; if (length > 0 && toread > length) { toread = length; @@ -460,9 +462,9 @@ PHP_FUNCTION(hash_update_file) php_stream_context *context; php_stream *stream; char *filename, buf[1024]; - int filename_len, n; + zend_str_size_int filename_len, n; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|r", &zhash, &filename, &filename_len, &zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rS|r", &zhash, &filename, &filename_len, &zcontext) == FAILURE) { return; } @@ -493,7 +495,7 @@ PHP_FUNCTION(hash_final) zend_bool raw_output = 0; zend_rsrc_list_entry *le; char *digest; - int digest_len; + zend_str_size_int digest_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|b", &zhash, &raw_output) == FAILURE) { return; @@ -505,7 +507,7 @@ PHP_FUNCTION(hash_final) digest = emalloc(digest_len + 1); hash->ops->hash_final((unsigned char *) digest, hash->context); if (hash->options & PHP_HASH_HMAC) { - int i; + zend_str_size_int i; /* Convert K to opad -- 0x6A = 0x36 ^ 0x5C */ for(i=0; i < hash->ops->block_size; i++) { @@ -591,9 +593,9 @@ PHP_FUNCTION(hash_algos) { HashPosition pos; char *str; - uint str_len; - long type; - ulong idx; + zend_str_size_uint str_len; + php_int_t type; + php_uint_t idx; array_init(return_value); for(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos); @@ -611,14 +613,16 @@ PHP_FUNCTION(hash_pbkdf2) { char *returnval, *algo, *salt, *pass = NULL; unsigned char *computed_salt, *digest, *temp, *result, *K1, *K2 = NULL; - long loops, i, j, algo_len, pass_len, iterations, length, digest_length = 0; - int argc, salt_len = 0; + php_int_t loops, i, j, iterations, length; + zend_str_size_int algo_len, pass_len, digest_length = 0; + int argc; + zend_str_size_int salt_len = 0; zend_bool raw_output = 0; const php_hash_ops *ops; void *context; argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters(argc TSRMLS_CC, "sssl|lb", &algo, &algo_len, &pass, &pass_len, &salt, &salt_len, &iterations, &length, &raw_output) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "SSSi|ib", &algo, &algo_len, &pass, &pass_len, &salt, &salt_len, &iterations, &length, &raw_output) == FAILURE) { return; } @@ -629,17 +633,17 @@ PHP_FUNCTION(hash_pbkdf2) } if (iterations <= 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Iterations must be a positive integer: %ld", iterations); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Iterations must be a positive integer: " ZEND_INT_FMT, iterations); RETURN_FALSE; } if (length < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to 0: %ld", length); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to 0: %zd", length); RETURN_FALSE; } - if (salt_len > INT_MAX - 4) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied salt is too long, max of INT_MAX - 4 bytes: %d supplied", salt_len); + if (salt_len > PHP_INT_MAX - 4) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied salt is too long, max of PHP_INT_MAX - 4 bytes: " ZEND_UINT_FMT " supplied", salt_len); RETURN_FALSE; } @@ -665,10 +669,10 @@ PHP_FUNCTION(hash_pbkdf2) } digest_length = length; if (!raw_output) { - digest_length = (long) ceil((float) length / 2.0); + digest_length = (php_int_t) ceil((float) length / 2.0); } - loops = (long) ceil((float) digest_length / (float) ops->digest_size); + loops = (php_int_t) ceil((float) digest_length / (float) ops->digest_size); result = safe_emalloc(loops, ops->digest_size, 0); @@ -684,7 +688,7 @@ PHP_FUNCTION(hash_pbkdf2) computed_salt[salt_len + 2] = (unsigned char) ((i & 0xFF00) >> 8); computed_salt[salt_len + 3] = (unsigned char) (i & 0xFF); - php_hash_hmac_round(digest, ops, context, K1, computed_salt, (long) salt_len + 4); + php_hash_hmac_round(digest, ops, context, K1, computed_salt, (php_int_t) salt_len + 4); php_hash_hmac_round(digest, ops, context, K2, digest, ops->digest_size); /* } */ @@ -831,9 +835,9 @@ PHP_FUNCTION(mhash) Gets the name of hash */ PHP_FUNCTION(mhash_get_hash_name) { - long algorithm; + php_int_t algorithm; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &algorithm) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &algorithm) == FAILURE) { return; } @@ -862,9 +866,9 @@ PHP_FUNCTION(mhash_count) Gets the block size of hash */ PHP_FUNCTION(mhash_get_block_size) { - long algorithm; + php_int_t algorithm; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &algorithm) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &algorithm) == FAILURE) { return; } RETVAL_FALSE; @@ -887,18 +891,16 @@ PHP_FUNCTION(mhash_get_block_size) Generates a key using hash functions */ PHP_FUNCTION(mhash_keygen_s2k) { - long algorithm, l_bytes; - int bytes; + php_int_t algorithm, l_bytes; char *password, *salt; - int password_len, salt_len; + zend_str_size_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, &l_bytes) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iSSi", &algorithm, &password, &password_len, &salt, &salt_len, &l_bytes) == FAILURE) { return; } - bytes = (int)l_bytes; - if (bytes <= 0){ + if (l_bytes <= 0){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "the byte parameter must be greater than 0"); RETURN_FALSE; } @@ -920,10 +922,10 @@ PHP_FUNCTION(mhash_keygen_s2k) unsigned char null = '\0'; void *context; char *key, *digest; - int i = 0, j = 0; - int block_size = ops->digest_size; - int times = bytes / block_size; - if (bytes % block_size != 0) times++; + php_int_t i = 0, j = 0; + zend_str_size_int block_size = ops->digest_size; + php_int_t times = l_bytes / block_size; + if (l_bytes % block_size != 0) times++; context = emalloc(ops->context_size); ops->hash_init(context); @@ -943,8 +945,8 @@ PHP_FUNCTION(mhash_keygen_s2k) memcpy( &key[i*block_size], digest, block_size); } - RETVAL_STRINGL(key, bytes, 1); - memset(key, 0, bytes); + RETVAL_STRINGL(key, l_bytes, 1); + memset(key, 0, l_bytes); efree(digest); efree(context); efree(key); @@ -1039,8 +1041,8 @@ PHP_MINFO_FUNCTION(hash) HashPosition pos; char buffer[2048]; char *s = buffer, *e = s + sizeof(buffer), *str; - ulong idx; - long type; + php_uint_t idx; + php_int_t type; for(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos); (type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, NULL, &idx, 0, &pos)) != HASH_KEY_NON_EXISTENT; diff --git a/ext/hash/hash_haval.c b/ext/hash/hash_haval.c index 7d8b496..4803aa2 100644 --- a/ext/hash/hash_haval.c +++ b/ext/hash/hash_haval.c @@ -282,7 +282,7 @@ PHP_HASH_HAVAL_INIT(5,256) /* {{{ PHP_HAVALUpdate */ -PHP_HASH_API void PHP_HAVALUpdate(PHP_HAVAL_CTX *context, const unsigned char *input, unsigned int inputLen) +PHP_HASH_API void PHP_HAVALUpdate(PHP_HAVAL_CTX *context, const unsigned char *input, zend_str_size_uint inputLen) { unsigned int i, index, partLen; diff --git a/ext/hash/hash_joaat.c b/ext/hash/hash_joaat.c index d73938d..38cfd71 100644 --- a/ext/hash/hash_joaat.c +++ b/ext/hash/hash_joaat.c @@ -40,7 +40,7 @@ PHP_HASH_API void PHP_JOAATInit(PHP_JOAAT_CTX *context) context->state = 0; } -PHP_HASH_API void PHP_JOAATUpdate(PHP_JOAAT_CTX *context, const unsigned char *input, unsigned int inputLen) +PHP_HASH_API void PHP_JOAATUpdate(PHP_JOAAT_CTX *context, const unsigned char *input, zend_str_size_uint inputLen) { context->state = joaat_buf((void *)input, inputLen, context->state); } diff --git a/ext/hash/hash_md.c b/ext/hash/hash_md.c index 25165ee..075f851 100644 --- a/ext/hash/hash_md.c +++ b/ext/hash/hash_md.c @@ -106,13 +106,13 @@ PHP_HASH_API void make_digest(char *md5str, unsigned char *digest) PHP_NAMED_FUNCTION(php_if_md5) { char *arg; - int arg_len; + zend_str_size_int arg_len; zend_bool raw_output = 0; char md5str[33]; PHP_MD5_CTX context; unsigned char digest[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -135,16 +135,16 @@ PHP_NAMED_FUNCTION(php_if_md5) PHP_NAMED_FUNCTION(php_if_md5_file) { char *arg; - int arg_len; + zend_str_size_int arg_len; zend_bool raw_output = 0; char md5str[33]; unsigned char buf[1024]; unsigned char digest[16]; PHP_MD5_CTX context; - int n; + zend_str_size_int n; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "P|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -541,9 +541,9 @@ PHP_HASH_API void PHP_MD4Init(PHP_MD4_CTX * context) operation, processing another message block, and updating the context. */ -PHP_HASH_API void PHP_MD4Update(PHP_MD4_CTX * context, const unsigned char *input, unsigned int inputLen) +PHP_HASH_API void PHP_MD4Update(PHP_MD4_CTX * context, const unsigned char *input, zend_str_size_uint inputLen) { - unsigned int i, index, partLen; + zend_str_size_uint i, index, partLen; /* Compute number of bytes mod 64 */ index = (unsigned int) ((context->count[0] >> 3) & 0x3F); @@ -654,7 +654,7 @@ static void MD2_Transform(PHP_MD2_CTX *context, const unsigned char *block) } } -PHP_HASH_API void PHP_MD2Update(PHP_MD2_CTX *context, const unsigned char *buf, unsigned int len) +PHP_HASH_API void PHP_MD2Update(PHP_MD2_CTX *context, const unsigned char *buf, zend_str_size_uint len) { const unsigned char *p = buf, *e = buf + len; diff --git a/ext/hash/hash_ripemd.c b/ext/hash/hash_ripemd.c index c7c53c6..0188c2a 100644 --- a/ext/hash/hash_ripemd.c +++ b/ext/hash/hash_ripemd.c @@ -187,9 +187,9 @@ static const unsigned char SS[80] = { Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is a multiple of 4. */ -static void RIPEMDDecode(php_hash_uint32 *output, const unsigned char *input, unsigned int len) +static void RIPEMDDecode(php_hash_uint32 *output, const unsigned char *input, zend_str_size_uint len) { - unsigned int i, j; + zend_str_size_uint i, j; for (i = 0, j = 0; j < len; i++, j += 4) output[i] = ((php_hash_uint32) input[j + 0]) | (((php_hash_uint32) input[j + 1]) << 8) | @@ -253,7 +253,7 @@ static void RIPEMD128Transform(php_hash_uint32 state[4], const unsigned char blo operation, processing another message block, and updating the context. */ -PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX * context, const unsigned char *input, unsigned int inputLen) +PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX * context, const unsigned char *input, zend_str_size_uint inputLen) { unsigned int i, index, partLen; @@ -351,7 +351,7 @@ static void RIPEMD256Transform(php_hash_uint32 state[8], const unsigned char blo operation, processing another message block, and updating the context. */ -PHP_HASH_API void PHP_RIPEMD256Update(PHP_RIPEMD256_CTX * context, const unsigned char *input, unsigned int inputLen) +PHP_HASH_API void PHP_RIPEMD256Update(PHP_RIPEMD256_CTX * context, const unsigned char *input, zend_str_size_uint inputLen) { unsigned int i, index, partLen; @@ -450,7 +450,7 @@ static void RIPEMD160Transform(php_hash_uint32 state[5], const unsigned char blo operation, processing another message block, and updating the context. */ -PHP_HASH_API void PHP_RIPEMD160Update(PHP_RIPEMD160_CTX * context, const unsigned char *input, unsigned int inputLen) +PHP_HASH_API void PHP_RIPEMD160Update(PHP_RIPEMD160_CTX * context, const unsigned char *input, zend_str_size_uint inputLen) { unsigned int i, index, partLen; @@ -558,7 +558,7 @@ static void RIPEMD320Transform(php_hash_uint32 state[10], const unsigned char bl operation, processing another message block, and updating the context. */ -PHP_HASH_API void PHP_RIPEMD320Update(PHP_RIPEMD320_CTX * context, const unsigned char *input, unsigned int inputLen) +PHP_HASH_API void PHP_RIPEMD320Update(PHP_RIPEMD320_CTX * context, const unsigned char *input, zend_str_size_uint inputLen) { unsigned int i, index, partLen; diff --git a/ext/hash/hash_sha.c b/ext/hash/hash_sha.c index 80d9f1f..cdb32a0 100644 --- a/ext/hash/hash_sha.c +++ b/ext/hash/hash_sha.c @@ -89,13 +89,13 @@ PHP_HASH_API void make_sha1_digest(char *sha1str, unsigned char *digest) PHP_FUNCTION(sha1) { char *arg; - int arg_len; + zend_str_size_int arg_len; zend_bool raw_output = 0; char sha1str[41]; PHP_SHA1_CTX context; unsigned char digest[20]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -119,7 +119,7 @@ PHP_FUNCTION(sha1) PHP_FUNCTION(sha1_file) { char *arg; - int arg_len; + zend_str_size_int arg_len; zend_bool raw_output = 0; char sha1str[41]; unsigned char buf[1024]; @@ -128,7 +128,7 @@ PHP_FUNCTION(sha1_file) int n; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "P|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -539,7 +539,7 @@ PHP_HASH_API void PHP_SHA224Init(PHP_SHA224_CTX * context) operation, processing another message block, and updating the context. */ -PHP_HASH_API void PHP_SHA224Update(PHP_SHA224_CTX * context, const unsigned char *input, unsigned int inputLen) +PHP_HASH_API void PHP_SHA224Update(PHP_SHA224_CTX * context, const unsigned char *input, zend_str_size_uint inputLen) { unsigned int i, index, partLen; @@ -616,7 +616,7 @@ PHP_HASH_API void PHP_SHA224Final(unsigned char digest[28], PHP_SHA224_CTX * con operation, processing another message block, and updating the context. */ -PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX * context, const unsigned char *input, unsigned int inputLen) +PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX * context, const unsigned char *input, zend_str_size_uint inputLen) { unsigned int i, index, partLen; @@ -830,7 +830,7 @@ static void SHA512Transform(php_hash_uint64 state[8], const unsigned char block[ operation, processing another message block, and updating the context. */ -PHP_HASH_API void PHP_SHA384Update(PHP_SHA384_CTX * context, const unsigned char *input, unsigned int inputLen) +PHP_HASH_API void PHP_SHA384Update(PHP_SHA384_CTX * context, const unsigned char *input, zend_str_size_uint inputLen) { unsigned int i, index, partLen; @@ -944,7 +944,7 @@ PHP_HASH_API void PHP_SHA512Init(PHP_SHA512_CTX * context) operation, processing another message block, and updating the context. */ -PHP_HASH_API void PHP_SHA512Update(PHP_SHA512_CTX * context, const unsigned char *input, unsigned int inputLen) +PHP_HASH_API void PHP_SHA512Update(PHP_SHA512_CTX * context, const unsigned char *input, zend_str_size_uint inputLen) { unsigned int i, index, partLen; diff --git a/ext/hash/php_hash.h b/ext/hash/php_hash.h index e925722..f3beaec 100644 --- a/ext/hash/php_hash.h +++ b/ext/hash/php_hash.h @@ -36,7 +36,7 @@ #define php_hash_uint64 uint64_t typedef void (*php_hash_init_func_t)(void *context); -typedef void (*php_hash_update_func_t)(void *context, const unsigned char *buf, unsigned int count); +typedef void (*php_hash_update_func_t)(void *context, const unsigned char *buf, zend_str_size_uint count); typedef void (*php_hash_final_func_t)(unsigned char *digest, void *context); typedef int (*php_hash_copy_func_t)(const void *ops, void *orig_context, void *dest_context); @@ -46,16 +46,16 @@ typedef struct _php_hash_ops { php_hash_final_func_t hash_final; php_hash_copy_func_t hash_copy; - int digest_size; - int block_size; - int context_size; + zend_str_size_int digest_size; + zend_str_size_int block_size; + zend_str_size_int context_size; } php_hash_ops; typedef struct _php_hash_data { const php_hash_ops *ops; void *context; - long options; + php_int_t options; unsigned char *key; } php_hash_data; @@ -135,14 +135,14 @@ PHP_FUNCTION(hash_final); PHP_FUNCTION(hash_algos); PHP_FUNCTION(hash_pbkdf2); -PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_len); +PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, zend_str_size_int algo_len); PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops *ops); PHP_HASH_API int php_hash_copy(const void *ops, void *orig_context, void *dest_context); -static inline void php_hash_bin2hex(char *out, const unsigned char *in, int in_len) +static inline void php_hash_bin2hex(char *out, const unsigned char *in, zend_str_size_int in_len) { static const char hexits[17] = "0123456789abcdef"; - int i; + zend_str_size_int i; for(i = 0; i < in_len; i++) { out[i * 2] = hexits[in[i] >> 4]; diff --git a/ext/hash/php_hash_haval.h b/ext/hash/php_hash_haval.h index 0e62f23..2ef0625 100644 --- a/ext/hash/php_hash_haval.h +++ b/ext/hash/php_hash_haval.h @@ -36,7 +36,7 @@ typedef struct { #define PHP_HASH_HAVAL_INIT_DECL(p,b) PHP_HASH_API void PHP_##p##HAVAL##b##Init(PHP_HAVAL_CTX *); \ PHP_HASH_API void PHP_HAVAL##b##Final(unsigned char*, PHP_HAVAL_CTX *); -PHP_HASH_API void PHP_HAVALUpdate(PHP_HAVAL_CTX *, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_HAVALUpdate(PHP_HAVAL_CTX *, const unsigned char *, zend_str_size_uint); PHP_HASH_HAVAL_INIT_DECL(3,128) PHP_HASH_HAVAL_INIT_DECL(3,160) diff --git a/ext/hash/php_hash_joaat.h b/ext/hash/php_hash_joaat.h index d4eacd9..6706048 100644 --- a/ext/hash/php_hash_joaat.h +++ b/ext/hash/php_hash_joaat.h @@ -26,7 +26,7 @@ typedef struct { } PHP_JOAAT_CTX; PHP_HASH_API void PHP_JOAATInit(PHP_JOAAT_CTX *context); -PHP_HASH_API void PHP_JOAATUpdate(PHP_JOAAT_CTX *context, const unsigned char *input, unsigned int inputLen); +PHP_HASH_API void PHP_JOAATUpdate(PHP_JOAAT_CTX *context, const unsigned char *input, zend_str_size_uint inputLen); PHP_HASH_API void PHP_JOAATFinal(unsigned char digest[16], PHP_JOAAT_CTX * context); static php_hash_uint32 joaat_buf(void *buf, size_t len, php_hash_uint32 hval); diff --git a/ext/hash/php_hash_md.h b/ext/hash/php_hash_md.h index 10b6f12..600c7b1 100644 --- a/ext/hash/php_hash_md.h +++ b/ext/hash/php_hash_md.h @@ -67,7 +67,7 @@ typedef struct { PHP_HASH_API void make_digest(char *md5str, unsigned char *digest); PHP_HASH_API void PHP_MD5Init(PHP_MD5_CTX *); -PHP_HASH_API void PHP_MD5Update(PHP_MD5_CTX *, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_MD5Update(PHP_MD5_CTX *, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_MD5Final(unsigned char[16], PHP_MD5_CTX *); PHP_NAMED_FUNCTION(php_if_md5); @@ -82,7 +82,7 @@ typedef struct { } PHP_MD4_CTX; PHP_HASH_API void PHP_MD4Init(PHP_MD4_CTX *); -PHP_HASH_API void PHP_MD4Update(PHP_MD4_CTX *context, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_MD4Update(PHP_MD4_CTX *context, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_MD4Final(unsigned char[16], PHP_MD4_CTX *); /* MD2 context */ @@ -94,7 +94,7 @@ typedef struct { } PHP_MD2_CTX; PHP_HASH_API void PHP_MD2Init(PHP_MD2_CTX *context); -PHP_HASH_API void PHP_MD2Update(PHP_MD2_CTX *context, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_MD2Update(PHP_MD2_CTX *context, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_MD2Final(unsigned char[16], PHP_MD2_CTX *); #endif diff --git a/ext/hash/php_hash_ripemd.h b/ext/hash/php_hash_ripemd.h index fde5c0f..5d4bd6b 100644 --- a/ext/hash/php_hash_ripemd.h +++ b/ext/hash/php_hash_ripemd.h @@ -48,19 +48,19 @@ typedef struct { } PHP_RIPEMD320_CTX; PHP_HASH_API void PHP_RIPEMD128Init(PHP_RIPEMD128_CTX *); -PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX *, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX *, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_RIPEMD128Final(unsigned char[16], PHP_RIPEMD128_CTX *); PHP_HASH_API void PHP_RIPEMD160Init(PHP_RIPEMD160_CTX *); -PHP_HASH_API void PHP_RIPEMD160Update(PHP_RIPEMD160_CTX *, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_RIPEMD160Update(PHP_RIPEMD160_CTX *, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_RIPEMD160Final(unsigned char[20], PHP_RIPEMD160_CTX *); PHP_HASH_API void PHP_RIPEMD256Init(PHP_RIPEMD256_CTX *); -PHP_HASH_API void PHP_RIPEMD256Update(PHP_RIPEMD256_CTX *, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_RIPEMD256Update(PHP_RIPEMD256_CTX *, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_RIPEMD256Final(unsigned char[32], PHP_RIPEMD256_CTX *); PHP_HASH_API void PHP_RIPEMD320Init(PHP_RIPEMD320_CTX *); -PHP_HASH_API void PHP_RIPEMD320Update(PHP_RIPEMD320_CTX *, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_RIPEMD320Update(PHP_RIPEMD320_CTX *, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_RIPEMD320Final(unsigned char[40], PHP_RIPEMD320_CTX *); #endif /* PHP_HASH_RIPEMD_H */ diff --git a/ext/hash/php_hash_sha.h b/ext/hash/php_hash_sha.h index bae7cf3..24e0d07 100644 --- a/ext/hash/php_hash_sha.h +++ b/ext/hash/php_hash_sha.h @@ -42,7 +42,7 @@ typedef struct { } PHP_SHA1_CTX; PHP_HASH_API void PHP_SHA1Init(PHP_SHA1_CTX *); -PHP_HASH_API void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_SHA1Final(unsigned char[20], PHP_SHA1_CTX *); PHP_FUNCTION(sha1); @@ -58,7 +58,7 @@ typedef struct { } PHP_SHA224_CTX; PHP_HASH_API void PHP_SHA224Init(PHP_SHA224_CTX *); -PHP_HASH_API void PHP_SHA224Update(PHP_SHA224_CTX *, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_SHA224Update(PHP_SHA224_CTX *, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_SHA224Final(unsigned char[28], PHP_SHA224_CTX *); /* SHA256 context. */ @@ -69,7 +69,7 @@ typedef struct { } PHP_SHA256_CTX; PHP_HASH_API void PHP_SHA256Init(PHP_SHA256_CTX *); -PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX *, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX *, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_SHA256Final(unsigned char[32], PHP_SHA256_CTX *); /* SHA384 context */ @@ -80,7 +80,7 @@ typedef struct { } PHP_SHA384_CTX; PHP_HASH_API void PHP_SHA384Init(PHP_SHA384_CTX *); -PHP_HASH_API void PHP_SHA384Update(PHP_SHA384_CTX *, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_SHA384Update(PHP_SHA384_CTX *, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_SHA384Final(unsigned char[48], PHP_SHA384_CTX *); /* SHA512 context */ @@ -91,7 +91,7 @@ typedef struct { } PHP_SHA512_CTX; PHP_HASH_API void PHP_SHA512Init(PHP_SHA512_CTX *); -PHP_HASH_API void PHP_SHA512Update(PHP_SHA512_CTX *, const unsigned char *, unsigned int); +PHP_HASH_API void PHP_SHA512Update(PHP_SHA512_CTX *, const unsigned char *, zend_str_size_uint); PHP_HASH_API void PHP_SHA512Final(unsigned char[64], PHP_SHA512_CTX *); #endif /* PHP_HASH_SHA_H */
« previous php.cvs (#74083) next »