File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -2990,8 +2990,8 @@ PHP_FUNCTION(sodium_crypto_kdf_derive_from_key)
2990
2990
char * ctx ;
2991
2991
char * key ;
2992
2992
zend_string * subkey ;
2993
- long subkey_id ;
2994
- long subkey_len ;
2993
+ zend_long subkey_id ;
2994
+ zend_long subkey_len ;
2995
2995
size_t ctx_len ;
2996
2996
size_t key_len ;
2997
2997
@@ -3006,7 +3006,7 @@ PHP_FUNCTION(sodium_crypto_kdf_derive_from_key)
3006
3006
zend_throw_exception (sodium_exception_ce , "subkey cannot be smaller than sodium_crypto_kdf_BYTES_MIN" , 0 );
3007
3007
return ;
3008
3008
}
3009
- if (subkey_len > crypto_kdf_BYTES_MAX ) {
3009
+ if (subkey_len > crypto_kdf_BYTES_MAX || subkey_len > SIZE_MAX ) {
3010
3010
zend_throw_exception (sodium_exception_ce , "subkey cannot be larger than sodium_crypto_kdf_BYTES_MAX" , 0 );
3011
3011
return ;
3012
3012
}
@@ -3033,7 +3033,7 @@ PHP_FUNCTION(sodium_crypto_kdf_derive_from_key)
3033
3033
salt [6 ] = (unsigned char ) (((uint64_t ) subkey_id ) >> 48 );
3034
3034
salt [7 ] = (unsigned char ) (((uint64_t ) subkey_id ) >> 56 );
3035
3035
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 );
3037
3037
if (crypto_generichash_blake2b_salt_personal ((unsigned char * ) ZSTR_VAL (subkey ),
3038
3038
(size_t ) subkey_len ,
3039
3039
NULL , 0 ,
You can’t perform that action at this time.
0 commit comments