com php-src: Revert "remove excessive checks and fix warnings": ext/sodium/libsodium.c
| From: | Anatol Belski | Date: | Tue, 11 Jul 2017 21:13:22 +0000 |
| Subject: | com php-src: Revert "remove excessive checks and fix warnings": ext/sodium/libsodium.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98521@lists.php.net to get a copy of this message | ||
Commit: d1ee66655b9df3ad7f8cfc08790964b6b90558e5
Author: Anatol Belski <ab@php.net> Tue, 11 Jul 2017 23:13:22 +0200
Parents: 2b37da9eda1e91ddb5ac6ff6f8862af2cae44f2a
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d1ee66655b9df3ad7f8cfc08790964b6b90558e5
Log:
Revert "remove excessive checks and fix warnings"
This reverts commit c620daecb4f8b1552eb3f63f6a699ea315825072.
Changed paths:
M ext/sodium/libsodium.c
Diff:
diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c
index b20ffc7..10c2331 100644
--- a/ext/sodium/libsodium.c
+++ b/ext/sodium/libsodium.c
@@ -1636,7 +1636,8 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256)
&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;
}
@@ -1649,11 +1650,11 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256)
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");
}
@@ -1682,7 +1683,7 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256_str)
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);
@@ -1691,11 +1692,11 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256_str)
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");
}
@@ -1759,7 +1760,8 @@ PHP_FUNCTION(sodium_crypto_pwhash)
&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;
}