&passwd, &passwd_len,
&salt, &salt_len,
&opslimit, &memlimit) == FAILURE ||
- hash_len <= 0 || opslimit <= 0 || memlimit <= 0) {
+ hash_len <= 0 || hash_len >= SIZE_MAX ||
+ opslimit <= 0 || memlimit <= 0 || memlimit > SIZE_MAX) {
zend_throw_exception(sodium_exception_ce, "crypto_pwhash_scryptsalsa208sha256(): invalid parameters", 0);
return;
}
0);
return;
}
- if ((size_t)opslimit < crypto_pwhash_scryptsalsa208sha256_opslimit_interactive()) {
+ if (opslimit < crypto_pwhash_scryptsalsa208sha256_opslimit_interactive()) {
zend_error(E_WARNING,
"number of operations for the scrypt function is low");
}
- if ((size_t)memlimit < crypto_pwhash_scryptsalsa208sha256_memlimit_interactive()) {
+ if (memlimit < crypto_pwhash_scryptsalsa208sha256_memlimit_interactive()) {
zend_error(E_WARNING,
"maximum memory for the scrypt function is low");
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll",
&passwd, &passwd_len,
&opslimit, &memlimit) == FAILURE ||
- opslimit <= 0 || memlimit <= 0) {
+ opslimit <= 0 || memlimit <= 0 || memlimit > SIZE_MAX) {
zend_throw_exception(sodium_exception_ce,
"crypto_pwhash_scryptsalsa208sha256_str(): invalid parameters",
0);
if (passwd_len <= 0) {
zend_error(E_WARNING, "empty password");
}
- if ((size_t)opslimit < crypto_pwhash_scryptsalsa208sha256_opslimit_interactive()) {
+ if (opslimit < crypto_pwhash_scryptsalsa208sha256_opslimit_interactive()) {
zend_error(E_WARNING,
"number of operations for the scrypt function is low");
}
- if ((size_t)memlimit < crypto_pwhash_scryptsalsa208sha256_memlimit_interactive()) {
+ if (memlimit < crypto_pwhash_scryptsalsa208sha256_memlimit_interactive()) {
zend_error(E_WARNING,
"maximum memory for the scrypt function is low");
}
&passwd, &passwd_len,
&salt, &salt_len,
&opslimit, &memlimit) == FAILURE ||
- hash_len <= 0 || opslimit <= 0 || memlimit <= 0) {
+ hash_len <= 0 || hash_len >= SIZE_MAX ||
+ opslimit <= 0 || memlimit <= 0 || memlimit > SIZE_MAX) {
zend_throw_exception(sodium_exception_ce, "crypto_pwhash(): invalid parameters", 0);
return;
}