Skip to content

Commit 631fc3c

Browse files
committed
sodium ext: long -> zend_long
1 parent 3140d40 commit 631fc3c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/sodium/libsodium.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,8 +2990,8 @@ PHP_FUNCTION(sodium_crypto_kdf_derive_from_key)
29902990
char *ctx;
29912991
char *key;
29922992
zend_string *subkey;
2993-
long subkey_id;
2994-
long subkey_len;
2993+
zend_long subkey_id;
2994+
zend_long subkey_len;
29952995
size_t ctx_len;
29962996
size_t key_len;
29972997

@@ -3006,7 +3006,7 @@ PHP_FUNCTION(sodium_crypto_kdf_derive_from_key)
30063006
zend_throw_exception(sodium_exception_ce, "subkey cannot be smaller than sodium_crypto_kdf_BYTES_MIN", 0);
30073007
return;
30083008
}
3009-
if (subkey_len > crypto_kdf_BYTES_MAX) {
3009+
if (subkey_len > crypto_kdf_BYTES_MAX || subkey_len > SIZE_MAX) {
30103010
zend_throw_exception(sodium_exception_ce, "subkey cannot be larger than sodium_crypto_kdf_BYTES_MAX", 0);
30113011
return;
30123012
}
@@ -3033,7 +3033,7 @@ PHP_FUNCTION(sodium_crypto_kdf_derive_from_key)
30333033
salt[6] = (unsigned char) (((uint64_t) subkey_id) >> 48);
30343034
salt[7] = (unsigned char) (((uint64_t) subkey_id) >> 56);
30353035
memset(salt + 8, 0, (sizeof salt) - 8);
3036-
subkey = zend_string_alloc(subkey_len, 0);
3036+
subkey = zend_string_alloc((size_t) subkey_len, 0);
30373037
if (crypto_generichash_blake2b_salt_personal((unsigned char *) ZSTR_VAL(subkey),
30383038
(size_t) subkey_len,
30393039
NULL, 0,

0 commit comments

Comments
 (0)