com php-src: ext/sodium: throw exceptions instead of errors: ext/sodium/libsodium.c

From: Date: Tue, 28 Nov 2017 12:56:11 +0000
Subject: com php-src: ext/sodium: throw exceptions instead of errors: ext/sodium/libsodium.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-100411@lists.php.net to get a copy of this message
Commit: c05cbd1e775fa69ed9939796a908390f2bfb4459 Author: Frank Denis <github@pureftpd.org> Tue, 28 Nov 2017 13:56:11 +0100 Parents: c219991c77e4c68f7d62963e18a1da778de0bbe0 Branches: PHP-7.2 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c05cbd1e775fa69ed9939796a908390f2bfb4459 Log: ext/sodium: throw exceptions instead of errors Changed paths: M ext/sodium/libsodium.c Diff: diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c index f08a272..a9cb17d 100644 --- a/ext/sodium/libsodium.c +++ b/ext/sodium/libsodium.c @@ -1853,11 +1853,13 @@ PHP_FUNCTION(sodium_crypto_pwhash) return; } if (opslimit < crypto_pwhash_OPSLIMIT_MIN) { - zend_error(E_ERROR, - "number of operations for the password hashing function is too low"); + zend_throw_exception(sodium_exception_ce, + "number of operations for the password hashing function is too low", 0); + return; } if (memlimit < crypto_pwhash_MEMLIMIT_MIN) { - zend_error(E_ERROR, "maximum memory for the password hashing function is too low"); + 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; @@ -1916,12 +1918,12 @@ PHP_FUNCTION(sodium_crypto_pwhash_str) zend_error(E_WARNING, "empty password"); } if (opslimit < crypto_pwhash_OPSLIMIT_MIN) { - zend_error(E_ERROR, - "number of operations for the password hashing function is too low"); + zend_throw_exception(sodium_exception_ce, + "number of operations for the password hashing function is too low", 0); } if (memlimit < crypto_pwhash_MEMLIMIT_MIN) { - zend_error(E_ERROR, - "maximum memory for the password hashing function is too low"); + 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 @@ -2030,12 +2032,12 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256) return; } if (opslimit < crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE) { - zend_error(E_ERROR, - "number of operations for the scrypt function is too low"); + 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_ERROR, - "maximum memory for the scrypt function is too low"); + 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 @@ -2077,12 +2079,12 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256_str) zend_error(E_WARNING, "empty password"); } if (opslimit < crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE) { - zend_error(E_ERROR, - "number of operations for the scrypt function is too low"); + 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_ERROR, - "maximum memory for the scrypt function is too low"); + 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);

« previous php.cvs (#100411) next »