Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions ext/hash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static void php_hash_do_hash(
}
php_stream_close(stream);
if (n < 0) {
efree(context);
php_hash_free_context(ops, context);
RETURN_FALSE;
}
} else {
Expand All @@ -401,7 +401,7 @@ static void php_hash_do_hash(

digest = zend_string_alloc(ops->digest_size, 0);
ops->hash_final((unsigned char *) ZSTR_VAL(digest), context);
efree(context);
php_hash_free_context(ops, context);

if (raw_output) {
ZSTR_VAL(digest)[ops->digest_size] = 0;
Expand Down Expand Up @@ -540,7 +540,7 @@ static void php_hash_do_hash_hmac(
}
php_stream_close(stream);
if (n < 0) {
efree(context);
php_hash_free_context(ops, context);
efree(K);
zend_string_release(digest);
RETURN_FALSE;
Expand All @@ -558,7 +558,7 @@ static void php_hash_do_hash_hmac(
/* Zero the key */
ZEND_SECURE_ZERO(K, ops->block_size);
efree(K);
efree(context);
php_hash_free_context(ops, context);

if (raw_output) {
ZSTR_VAL(digest)[ops->digest_size] = 0;
Expand Down Expand Up @@ -817,7 +817,7 @@ PHP_FUNCTION(hash_final)
ZSTR_VAL(digest)[digest_len] = 0;

/* Invalidate the object from further use */
efree(hash->context);
php_hash_free_context(hash->ops, hash->context);
hash->context = NULL;

if (raw_output) {
Expand Down Expand Up @@ -975,7 +975,7 @@ PHP_FUNCTION(hash_hkdf)
ZEND_SECURE_ZERO(digest, ops->digest_size);
ZEND_SECURE_ZERO(prk, ops->digest_size);
efree(K);
efree(context);
php_hash_free_context(ops, context);
efree(prk);
efree(digest);
ZSTR_VAL(returnval)[length] = 0;
Expand Down Expand Up @@ -1091,7 +1091,7 @@ PHP_FUNCTION(hash_pbkdf2)
efree(K1);
efree(K2);
efree(computed_salt);
efree(context);
php_hash_free_context(ops, context);
efree(digest);
efree(temp);

Expand Down Expand Up @@ -1347,7 +1347,7 @@ PHP_FUNCTION(mhash_keygen_s2k)
RETVAL_STRINGL(key, bytes);
ZEND_SECURE_ZERO(key, bytes);
efree(digest);
efree(context);
php_hash_free_context(ops, context);
efree(key);
}
}
Expand Down Expand Up @@ -1377,7 +1377,7 @@ static void php_hashcontext_dtor(zend_object *obj) {
php_hashcontext_object *hash = php_hashcontext_from_object(obj);

if (hash->context) {
efree(hash->context);
php_hash_free_context(hash->ops, hash->context);
hash->context = NULL;
}

Expand Down Expand Up @@ -1413,7 +1413,7 @@ static zend_object *php_hashcontext_clone(zend_object *zobj) {
newobj->ops->hash_init(newobj->context, NULL);

if (SUCCESS != newobj->ops->hash_copy(newobj->ops, oldobj->context, newobj->context)) {
efree(newobj->context);
php_hash_free_context(newobj->ops, newobj->context);
newobj->context = NULL;
return znew;
}
Expand Down
1 change: 1 addition & 0 deletions ext/hash/hash_adler32.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@ const php_hash_ops php_hash_adler32_ops = {
4, /* what to say here? */
4,
sizeof(PHP_ADLER32_CTX),
0,
0
};
3 changes: 3 additions & 0 deletions ext/hash/hash_crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const php_hash_ops php_hash_crc32_ops = {
4, /* what to say here? */
4,
sizeof(PHP_CRC32_CTX),
0,
0
};

Expand All @@ -117,6 +118,7 @@ const php_hash_ops php_hash_crc32b_ops = {
4, /* what to say here? */
4,
sizeof(PHP_CRC32_CTX),
0,
0
};

Expand All @@ -132,5 +134,6 @@ const php_hash_ops php_hash_crc32c_ops = {
4, /* what to say here? */
4,
sizeof(PHP_CRC32_CTX),
0,
0
};
4 changes: 4 additions & 0 deletions ext/hash/hash_fnv.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const php_hash_ops php_hash_fnv132_ops = {
4,
4,
sizeof(PHP_FNV132_CTX),
0,
0
};

Expand All @@ -47,6 +48,7 @@ const php_hash_ops php_hash_fnv1a32_ops = {
4,
4,
sizeof(PHP_FNV132_CTX),
0,
0
};

Expand All @@ -62,6 +64,7 @@ const php_hash_ops php_hash_fnv164_ops = {
8,
4,
sizeof(PHP_FNV164_CTX),
0,
0
};

Expand All @@ -77,6 +80,7 @@ const php_hash_ops php_hash_fnv1a64_ops = {
8,
4,
sizeof(PHP_FNV164_CTX),
0,
0
};

Expand Down
6 changes: 4 additions & 2 deletions ext/hash/hash_gost.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ const php_hash_ops php_hash_gost_ops = {
32,
32,
sizeof(PHP_GOST_CTX),
1
1,
0
};

const php_hash_ops php_hash_gost_crypto_ops = {
Expand All @@ -344,5 +345,6 @@ const php_hash_ops php_hash_gost_crypto_ops = {
32,
32,
sizeof(PHP_GOST_CTX),
1
1,
0
};
2 changes: 1 addition & 1 deletion ext/hash/hash_haval.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const php_hash_ops php_hash_##p##haval##b##_ops = { \
php_hash_serialize, \
php_hash_unserialize, \
PHP_HAVAL_SPEC, \
((b) / 8), 128, sizeof(PHP_HAVAL_CTX), 1 }; \
((b) / 8), 128, sizeof(PHP_HAVAL_CTX), 1, 0 }; \
PHP_HASH_API void PHP_##p##HAVAL##b##Init(PHP_HAVAL_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args) \
{ int i; context->count[0] = context->count[1] = 0; \
for(i = 0; i < 8; i++) context->state[i] = D0[i]; \
Expand Down
1 change: 1 addition & 0 deletions ext/hash/hash_joaat.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const php_hash_ops php_hash_joaat_ops = {
4,
4,
sizeof(PHP_JOAAT_CTX),
0,
0
};

Expand Down
9 changes: 6 additions & 3 deletions ext/hash/hash_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const php_hash_ops php_hash_md5_ops = {
16,
64,
sizeof(PHP_MD5_CTX),
1
1,
0
};

const php_hash_ops php_hash_md4_ops = {
Expand All @@ -44,7 +45,8 @@ const php_hash_ops php_hash_md4_ops = {
16,
64,
sizeof(PHP_MD4_CTX),
1
1,
0
};

static int php_md2_unserialize(php_hashcontext_object *hash, zend_long magic, const zval *zv);
Expand All @@ -61,7 +63,8 @@ const php_hash_ops php_hash_md2_ops = {
16,
16,
sizeof(PHP_MD2_CTX),
1
1,
0
};

/* MD common stuff */
Expand Down
3 changes: 3 additions & 0 deletions ext/hash/hash_murmur.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const php_hash_ops php_hash_murmur3a_ops = {
4,
4,
sizeof(PHP_MURMUR3A_CTX),
0,
0
};

Expand Down Expand Up @@ -95,6 +96,7 @@ const php_hash_ops php_hash_murmur3c_ops = {
16,
4,
sizeof(PHP_MURMUR3C_CTX),
0,
0
};

Expand Down Expand Up @@ -174,6 +176,7 @@ const php_hash_ops php_hash_murmur3f_ops = {
16,
8,
sizeof(PHP_MURMUR3F_CTX),
0,
0
};

Expand Down
12 changes: 8 additions & 4 deletions ext/hash/hash_ripemd.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const php_hash_ops php_hash_ripemd128_ops = {
16,
64,
sizeof(PHP_RIPEMD128_CTX),
1
1,
0
};

const php_hash_ops php_hash_ripemd160_ops = {
Expand All @@ -48,7 +49,8 @@ const php_hash_ops php_hash_ripemd160_ops = {
20,
64,
sizeof(PHP_RIPEMD160_CTX),
1
1,
0
};

const php_hash_ops php_hash_ripemd256_ops = {
Expand All @@ -63,7 +65,8 @@ const php_hash_ops php_hash_ripemd256_ops = {
32,
64,
sizeof(PHP_RIPEMD256_CTX),
1
1,
0
};

const php_hash_ops php_hash_ripemd320_ops = {
Expand All @@ -78,7 +81,8 @@ const php_hash_ops php_hash_ripemd320_ops = {
40,
64,
sizeof(PHP_RIPEMD320_CTX),
1
1,
0
};

/* {{{ PHP_RIPEMD128Init
Expand Down
21 changes: 14 additions & 7 deletions ext/hash/hash_sha.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ const php_hash_ops php_hash_sha1_ops = {
20,
64,
sizeof(PHP_SHA1_CTX),
1
1,
0
};

/* sha224/sha256 */
Expand All @@ -92,7 +93,8 @@ const php_hash_ops php_hash_sha256_ops = {
32,
64,
sizeof(PHP_SHA256_CTX),
1
1,
0
};

const php_hash_ops php_hash_sha224_ops = {
Expand All @@ -107,7 +109,8 @@ const php_hash_ops php_hash_sha224_ops = {
28,
64,
sizeof(PHP_SHA224_CTX),
1
1,
0
};

#define ROTR32(b,x) ((x >> b) | (x << (32 - b)))
Expand Down Expand Up @@ -624,7 +627,8 @@ const php_hash_ops php_hash_sha384_ops = {
48,
128,
sizeof(PHP_SHA384_CTX),
1
1,
0
};

/* {{{ PHP_SHA512InitArgs
Expand Down Expand Up @@ -803,7 +807,8 @@ const php_hash_ops php_hash_sha512_ops = {
64,
128,
sizeof(PHP_SHA512_CTX),
1
1,
0
};

const php_hash_ops php_hash_sha512_256_ops = {
Expand All @@ -818,7 +823,8 @@ const php_hash_ops php_hash_sha512_256_ops = {
32,
128,
sizeof(PHP_SHA512_CTX),
1
1,
0
};

const php_hash_ops php_hash_sha512_224_ops = {
Expand All @@ -833,5 +839,6 @@ const php_hash_ops php_hash_sha512_224_ops = {
28,
128,
sizeof(PHP_SHA512_CTX),
1
1,
0
};
6 changes: 4 additions & 2 deletions ext/hash/hash_sha3.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ const php_hash_ops php_hash_sha3_##bits##_ops = { \
bits >> 3, \
(1600 - (2 * bits)) >> 3, \
sizeof(PHP_SHA3_##bits##_CTX), \
1 \
1, \
0 \
}

#else
Expand Down Expand Up @@ -339,7 +340,8 @@ const php_hash_ops php_hash_sha3_##bits##_ops = { \
bits >> 3, \
(1600 - (2 * bits)) >> 3, \
sizeof(PHP_SHA3_CTX), \
1 \
1, \
0 \
}

#endif
Expand Down
3 changes: 2 additions & 1 deletion ext/hash/hash_snefru.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,6 @@ const php_hash_ops php_hash_snefru_ops = {
32,
32,
sizeof(PHP_SNEFRU_CTX),
1
1,
0
};
3 changes: 2 additions & 1 deletion ext/hash/hash_tiger.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ static int php_tiger_unserialize(php_hashcontext_object *hash, zend_long magic,
b/8, \
64, \
sizeof(PHP_TIGER_CTX), \
1 \
1, \
0 \
}

PHP_HASH_TIGER_OPS(3, 128);
Expand Down
3 changes: 2 additions & 1 deletion ext/hash/hash_whirlpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,5 +457,6 @@ const php_hash_ops php_hash_whirlpool_ops = {
64,
64,
sizeof(PHP_WHIRLPOOL_CTX),
1
1,
0
};
Loading
Loading