1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-02-08 03:54:20 +01:00

Refactor.

- retrieveURLasync() always returns FALSE on failure now,
	before it might have returned a string.

- use array_shift($a) to pop first element,
	safer than $a[0];

- this commit might affect what is written to LOG_DEBUG,
	since now we only write the YK-KSM message when we
	are certain to have a valid response.
This commit is contained in:
Jean Paul Galea 2015-07-17 22:25:42 +02:00
parent 60a487a996
commit c5b6b3c567
2 changed files with 8 additions and 10 deletions

View File

@ -161,7 +161,6 @@ function retrieveURLasync($ident, $urls, $logger, $ans_req=1, $match="^OK", $ret
$ch[$handle] = $handle; $ch[$handle] = $handle;
} }
$str = false;
$ans_arr = array(); $ans_arr = array();
do do
@ -223,7 +222,7 @@ function retrieveURLasync($ident, $urls, $logger, $ans_req=1, $match="^OK", $ret
if (count($ans_arr) > 0) if (count($ans_arr) > 0)
return $ans_arr; return $ans_arr;
return $str; return false;
} }
function KSMdecryptOTP($urls, $logger, $curlopts) function KSMdecryptOTP($urls, $logger, $curlopts)
@ -237,15 +236,14 @@ function KSMdecryptOTP($urls, $logger, $curlopts)
$response = retrieveURLasync('YK-KSM', $urls, $logger, $ans_req=1, $match='^OK', $returl=False, $timeout=10, $curlopts); $response = retrieveURLasync('YK-KSM', $urls, $logger, $ans_req=1, $match='^OK', $returl=False, $timeout=10, $curlopts);
if (is_array($response)) if ($response === FALSE)
{ {
$response = $response[0]; return false;
} }
if ($response) $response = array_shift($response);
{
$logger->log(LOG_DEBUG, log_format('YK-KSM response: ', $response)); $logger->log(LOG_DEBUG, log_format('YK-KSM response: ', $response));
}
if (sscanf($response, if (sscanf($response,
'OK counter=%04x low=%04x high=%02x use=%02x', 'OK counter=%04x low=%04x high=%02x use=%02x',

View File

@ -454,9 +454,9 @@ class SyncLib
*/ */
$ans_arr = retrieveURLasync('YK-VAL sync', $urls, $this->myLog, $ans_req, $match='status=OK', $returl=True, $timeout, $this->curlopts); $ans_arr = retrieveURLasync('YK-VAL sync', $urls, $this->myLog, $ans_req, $match='status=OK', $returl=True, $timeout, $this->curlopts);
if (!is_array($ans_arr)) { if ($ans_arr === FALSE) {
$this->log(LOG_WARNING, 'No responses from validation server pool'); $this->log(LOG_WARNING, 'No responses from validation server pool');
$ans_arr=array(); $ans_arr = array();
} }
/* /*