com php-src: remove excessive checks and fix warnings: ext/sodium/libsodium.c
| From: | Anatol Belski | Date: | Tue, 11 Jul 2017 09:03:09 +0000 |
| Subject: | com php-src: remove excessive checks and fix warnings: ext/sodium/libsodium.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98511@lists.php.net to get a copy of this message | ||
Commit: c620daecb4f8b1552eb3f63f6a699ea315825072
Author: Anatol Belski <ab@php.net> Tue, 11 Jul 2017 11:03:09 +0200
Parents: cbbf579f2178073b4d88c0bd2f2052e853a32a1e
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c620daecb4f8b1552eb3f63f6a699ea315825072
Log:
remove excessive checks and fix warnings
Changed paths:
M ext/sodium/libsodium.c
Diff:
diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c
index 10c2331..b20ffc7 100644
--- a/ext/sodium/libsodium.c
+++ b/ext/sodium/libsodium.c
@@ -1636,8 +1636,7 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256)
&passwd, &passwd_len,
&salt, &salt_len,
&opslimit, &memlimit) == FAILURE ||
- hash_len <= 0 || hash_len >= SIZE_MAX ||
- opslimit <= 0 || memlimit <= 0 || memlimit > SIZE_MAX) {
+ hash_len <= 0 || opslimit <= 0 || memlimit <= 0) {
zend_throw_exception(sodium_exception_ce, "crypto_pwhash_scryptsalsa208sha256(): invalid
parameters", 0);
return;
}
@@ -1650,11 +1649,11 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256)
0);
return;
}
- if (opslimit < crypto_pwhash_scryptsalsa208sha256_opslimit_interactive()) {
+ if ((size_t)opslimit < crypto_pwhash_scryptsalsa208sha256_opslimit_interactive()) {
zend_error(E_WARNING,
"number of operations for the scrypt function is low");
}
- if (memlimit < crypto_pwhash_scryptsalsa208sha256_memlimit_interactive()) {
+ if ((size_t)memlimit < crypto_pwhash_scryptsalsa208sha256_memlimit_interactive()) {
zend_error(E_WARNING,
"maximum memory for the scrypt function is low");
}
@@ -1683,7 +1682,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 || memlimit > SIZE_MAX) {
+ opslimit <= 0 || memlimit <= 0) {
zend_throw_exception(sodium_exception_ce,
"crypto_pwhash_scryptsalsa208sha256_str(): invalid parameters",
0);
@@ -1692,11 +1691,11 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256_str)
if (passwd_len <= 0) {
zend_error(E_WARNING, "empty password");
}
- if (opslimit < crypto_pwhash_scryptsalsa208sha256_opslimit_interactive()) {
+ if ((size_t)opslimit < crypto_pwhash_scryptsalsa208sha256_opslimit_interactive()) {
zend_error(E_WARNING,
"number of operations for the scrypt function is low");
}
- if (memlimit < crypto_pwhash_scryptsalsa208sha256_memlimit_interactive()) {
+ if ((size_t)memlimit < crypto_pwhash_scryptsalsa208sha256_memlimit_interactive()) {
zend_error(E_WARNING,
"maximum memory for the scrypt function is low");
}
@@ -1760,8 +1759,7 @@ PHP_FUNCTION(sodium_crypto_pwhash)
&passwd, &passwd_len,
&salt, &salt_len,
&opslimit, &memlimit) == FAILURE ||
- hash_len <= 0 || hash_len >= SIZE_MAX ||
- opslimit <= 0 || memlimit <= 0 || memlimit > SIZE_MAX) {
+ hash_len <= 0 || opslimit <= 0 || memlimit <= 0) {
zend_throw_exception(sodium_exception_ce, "crypto_pwhash(): invalid parameters", 0);
return;
}