From 34443bf562d44b97ce633fee77fd45f840d9b692 Mon Sep 17 00:00:00 2001 From: schengawegga Date: Sun, 5 Nov 2023 00:12:49 +0100 Subject: [PATCH] bugfix: return pear error object on factory with scram authentication method --- Auth/SASL.php | 10 +++++++++- Auth/SASL/SCRAM.php | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Auth/SASL.php b/Auth/SASL.php index 3693aa2..0e6ae7a 100755 --- a/Auth/SASL.php +++ b/Auth/SASL.php @@ -127,9 +127,17 @@ public static function factory($type) require_once($filename); if (isset($parameter)) - $obj = new $classname($parameter); + { + $obj = new $classname(); + $check = $obj->factory($parameter); + if (PEAR::isError($check)) { + return $check; + } + } else + { $obj = new $classname(); + } return $obj; } } diff --git a/Auth/SASL/SCRAM.php b/Auth/SASL/SCRAM.php index a43abd5..db234c5 100644 --- a/Auth/SASL/SCRAM.php +++ b/Auth/SASL/SCRAM.php @@ -68,7 +68,18 @@ class Auth_SASL_SCRAM extends Auth_SASL_Common * format of core PHP hash function. * @access public */ - function __construct($hash) + function __construct() + { + } + + /** + * Construct a SCRAM-H client where 'H' is a cryptographic hash function. + * + * @param string $hash The name cryptographic hash function 'H' as registered by IANA in the "Hash Function Textual + * Names" registry. + * @return boolean|object true or PEAR::isError object + */ + public function factory($hash) { // Though I could be strict, I will actually also accept the naming used in the PHP core hash framework. // For instance "sha1" is accepted, while the registered hash name should be "SHA-1". @@ -109,7 +120,8 @@ function __construct($hash) }; $this->hmac = array($this, '_HMAC_SHA1'); } - else { + else + { return PEAR::raiseError('Invalid SASL mechanism type'); }