diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2017-11-29 17:06:47 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2017-11-29 17:06:47 +0100 |
commit | fa5c186cc00fb31c4953cb0006f9e8bc066ac77a (patch) | |
tree | d60e3af17d1043da167b44ad486eb59d73c6c844 | |
parent | 03da5f8e30cc65584d38d478ea566062ff99579b (diff) | |
parent | 995ac8a09484b91aa9da6dc7387a6506e452fff2 (diff) | |
download | php-git-fa5c186cc00fb31c4953cb0006f9e8bc066ac77a.tar.gz |
Merge branch 'PHP-7.2'
* PHP-7.2:
Define floorf if system doesn't have it (follow up for 22c48761)
Revert "Revert "ext/sodium: pwhash: do not warn on low parameters"" This reverts commit a1845b7fdb5916b0951146ca18bb67ca83854733.
-rw-r--r-- | ext/gd/libgd/gd_interpolation.c | 10 | ||||
-rw-r--r-- | ext/sodium/libsodium.c | 61 |
2 files changed, 48 insertions, 23 deletions
diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index 07eefd6488..2a2479c912 100644 --- a/ext/gd/libgd/gd_interpolation.c +++ b/ext/gd/libgd/gd_interpolation.c @@ -66,6 +66,16 @@ TODO: # include <emmintrin.h> #endif +#ifndef HAVE_FLOORF +# define HAVE_FLOORF 0 +#endif +#if HAVE_FLOORF == 0 +# ifndef floorf +/* float floorf(float x);*/ +# define floorf(x) ((float)(floor(x))) +# endif +#endif + #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) #endif diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c index 06a763627d..a9cb17d772 100644 --- a/ext/sodium/libsodium.c +++ b/ext/sodium/libsodium.c @@ -233,6 +233,19 @@ ZEND_END_ARG_INFO() # undef crypto_secretstream_xchacha20poly1305_ABYTES #endif +#ifndef crypto_pwhash_OPSLIMIT_MIN +# define crypto_pwhash_OPSLIMIT_MIN crypto_pwhash_OPSLIMIT_INTERACTIVE +#endif +#ifndef crypto_pwhash_MEMLIMIT_MIN +# define crypto_pwhash_MEMLIMIT_MIN crypto_pwhash_MEMLIMIT_INTERACTIVE +#endif +#ifndef crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN +# define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE +#endif +#ifndef crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN +# define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE +#endif + const zend_function_entry sodium_functions[] = { PHP_FE(sodium_crypto_aead_aes256gcm_is_available, AI_None) #ifdef HAVE_AESGCM @@ -1839,12 +1852,14 @@ PHP_FUNCTION(sodium_crypto_pwhash) zend_throw_exception(sodium_exception_ce, "salt should be SODIUM_CRYPTO_PWHASH_SALTBYTES bytes", 0); return; } - if (opslimit < crypto_pwhash_OPSLIMIT_INTERACTIVE) { - zend_error(E_WARNING, - "number of operations for the password hashing function is low"); + if (opslimit < crypto_pwhash_OPSLIMIT_MIN) { + zend_throw_exception(sodium_exception_ce, + "number of operations for the password hashing function is too low", 0); + return; } - if (memlimit < crypto_pwhash_MEMLIMIT_INTERACTIVE) { - zend_error(E_WARNING, "maximum memory for the password hashing function is low"); + if (memlimit < crypto_pwhash_MEMLIMIT_MIN) { + zend_throw_exception(sodium_exception_ce, + "maximum memory for the password hashing function is too low", 0); } hash = zend_string_alloc((size_t) hash_len, 0); ret = -1; @@ -1902,13 +1917,13 @@ PHP_FUNCTION(sodium_crypto_pwhash_str) if (passwd_len <= 0) { zend_error(E_WARNING, "empty password"); } - if (opslimit < crypto_pwhash_OPSLIMIT_INTERACTIVE) { - zend_error(E_WARNING, - "number of operations for the password hashing function is low"); + if (opslimit < crypto_pwhash_OPSLIMIT_MIN) { + zend_throw_exception(sodium_exception_ce, + "number of operations for the password hashing function is too low", 0); } - if (memlimit < crypto_pwhash_MEMLIMIT_INTERACTIVE) { - zend_error(E_WARNING, - "maximum memory for the password hashing function is low"); + if (memlimit < crypto_pwhash_MEMLIMIT_MIN) { + zend_throw_exception(sodium_exception_ce, + "maximum memory for the password hashing function is too low", 0); } hash_str = zend_string_alloc(crypto_pwhash_STRBYTES - 1, 0); if (crypto_pwhash_str @@ -2016,13 +2031,13 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256) 0); return; } - if (opslimit < crypto_pwhash_scryptsalsa208sha256_opslimit_interactive()) { - zend_error(E_WARNING, - "number of operations for the scrypt function is low"); + if (opslimit < crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE) { + zend_throw_exception(sodium_exception_ce, + "number of operations for the scrypt function is too low", 0); } - if (memlimit < crypto_pwhash_scryptsalsa208sha256_memlimit_interactive()) { - zend_error(E_WARNING, - "maximum memory for the scrypt function is low"); + if (memlimit < crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE) { + zend_throw_exception(sodium_exception_ce, + "maximum memory for the scrypt function is too low", 0); } hash = zend_string_alloc((size_t) hash_len, 0); if (crypto_pwhash_scryptsalsa208sha256 @@ -2063,13 +2078,13 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256_str) if (passwd_len <= 0) { zend_error(E_WARNING, "empty password"); } - if (opslimit < crypto_pwhash_scryptsalsa208sha256_opslimit_interactive()) { - zend_error(E_WARNING, - "number of operations for the scrypt function is low"); + if (opslimit < crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE) { + zend_throw_exception(sodium_exception_ce, + "number of operations for the scrypt function is too low", 0); } - if (memlimit < crypto_pwhash_scryptsalsa208sha256_memlimit_interactive()) { - zend_error(E_WARNING, - "maximum memory for the scrypt function is low"); + if (memlimit < crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE) { + zend_throw_exception(sodium_exception_ce, + "maximum memory for the scrypt function is too low", 0); } hash_str = zend_string_alloc (crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1, 0); |