Skip to content

Commit 26ac3aa

Browse files
committed
Added new version of the openid library to the module.
1 parent f13b004 commit 26ac3aa

File tree

14 files changed

+66
-20
lines changed

14 files changed

+66
-20
lines changed

include/openid/Auth/OpenID/Association.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ function checkMessageSignature($message)
374374
}
375375

376376
$calculated_sig = $this->getMessageSignature($message);
377-
return $calculated_sig == $sig;
377+
return Auth_OpenID_CryptUtil::constEq($calculated_sig, $sig);
378378
}
379379
}
380380

include/openid/Auth/OpenID/BigMath.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ function Auth_OpenID_detectMathLibrary($exts)
365365
{
366366
$loaded = false;
367367

368-
$hasDl = function_exists('dl');
369368
foreach ($exts as $extension) {
370369
if (extension_loaded($extension['extension'])) {
371370
return $extension;

include/openid/Auth/OpenID/Consumer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,10 @@ function _idResCheckSignature($message, $server_url)
957957
}
958958

959959
if (!$assoc->checkMessageSignature($message)) {
960+
// If we get a "bad signature" here, it means that the association
961+
// is unrecoverabley corrupted in some way. Any futher attempts
962+
// to login with this association is likely to fail. Drop it.
963+
$this->store->removeAssociation($server_url, $assoc_handle);
960964
return new Auth_OpenID_FailureResponse(null,
961965
"Bad signature");
962966
}
@@ -1181,7 +1185,7 @@ function _discoverAndVerify($claimed_id, $to_match_endpoints)
11811185
// oidutil.log('Performing discovery on %s' % (claimed_id,))
11821186
list($unused, $services) = call_user_func($this->discoverMethod,
11831187
$claimed_id,
1184-
$this->fetcher);
1188+
&$this->fetcher);
11851189

11861190
if (!$services) {
11871191
return new Auth_OpenID_FailureResponse(null,

include/openid/Auth/OpenID/CryptUtil.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,19 @@ static function randomString($length, $population = null)
104104

105105
return $str;
106106
}
107+
108+
static function constEq($s1, $s2)
109+
{
110+
if (strlen($s1) != strlen($s2)) {
111+
return false;
112+
}
113+
114+
$result = true;
115+
$length = strlen($s1);
116+
for ($i = 0; $i < $length; $i++) {
117+
$result &= ($s1[$i] == $s2[$i]);
118+
}
119+
return $result;
120+
}
107121
}
108122

include/openid/Auth/OpenID/HMAC.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ function Auth_OpenID_HMACSHA1($key, $text)
6060
$key = Auth_OpenID_SHA1($key, true);
6161
}
6262

63+
if (function_exists('hash_hmac') &&
64+
function_exists('hash_algos') &&
65+
(in_array('sha1', hash_algos()))) {
66+
return hash_hmac('sha1', $text, $key, true);
67+
}
68+
// Home-made solution
69+
6370
$key = str_pad($key, Auth_OpenID_SHA1_BLOCKSIZE, chr(0x00));
6471
$ipad = str_repeat(chr(0x36), Auth_OpenID_SHA1_BLOCKSIZE);
6572
$opad = str_repeat(chr(0x5c), Auth_OpenID_SHA1_BLOCKSIZE);

include/openid/Auth/OpenID/Message.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ function toFormMarkup($action_url, $form_tag_attrs = null,
684684
foreach ($this->toPostArgs() as $name => $value) {
685685
$form .= sprintf(
686686
"<input type=\"hidden\" name=\"%s\" value=\"%s\" />\n",
687-
$name, $value);
687+
$name, urldecode($value));
688688
}
689689

690690
$form .= sprintf("<input type=\"submit\" value=\"%s\" />\n",

include/openid/Auth/OpenID/Parse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function match($regexp, $text, &$match)
227227
if (!mb_ereg_search($regexp)) {
228228
return false;
229229
}
230-
list($match) = mb_ereg_search_getregs();
230+
$match = mb_ereg_search_getregs();
231231
return true;
232232
}
233233

@@ -269,7 +269,7 @@ function parseLinkAttrs($html)
269269

270270
// Try to find the <HEAD> tag.
271271
$head_re = $this->headFind();
272-
$head_match = '';
272+
$head_match = array();
273273
if (!$this->match($head_re, $stripped, $head_match)) {
274274
ini_set( 'pcre.backtrack_limit', $old_btlimit );
275275
return array();
@@ -278,7 +278,7 @@ function parseLinkAttrs($html)
278278
$link_data = array();
279279
$link_matches = array();
280280

281-
if (!preg_match_all($this->_link_find, $head_match[2],
281+
if (!preg_match_all($this->_link_find, $head_match[0],
282282
$link_matches)) {
283283
ini_set( 'pcre.backtrack_limit', $old_btlimit );
284284
return array();

include/openid/Auth/OpenID/Server.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -817,11 +817,11 @@ function equals($other)
817817
*/
818818
function returnToVerified()
819819
{
820-
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
820+
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
821821
return call_user_func_array($this->verifyReturnTo,
822822
array($this->trust_root, $this->return_to, $fetcher));
823823
}
824-
824+
825825
static function fromMessage($message, $server)
826826
{
827827
$mode = $message->getArg(Auth_OpenID_OPENID_NS, 'mode');
@@ -1704,7 +1704,7 @@ function handleRequest($request)
17041704
{
17051705
if (method_exists($this, "openid_" . $request->mode)) {
17061706
$handler = array($this, "openid_" . $request->mode);
1707-
return call_user_func($handler, $request);
1707+
return call_user_func($handler, &$request);
17081708
}
17091709
return null;
17101710
}

include/openid/Auth/OpenID/TrustRoot.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ function Auth_OpenID_getAllowedReturnURLs($relying_party_url, $fetcher,
413413
}
414414

415415
call_user_func_array($discover_function,
416-
array($relying_party_url, $fetcher));
416+
array($relying_party_url, &$fetcher));
417417

418418
$return_to_urls = array();
419419
$matching_endpoints = Auth_OpenID_extractReturnURL($endpoints);

include/openid/Auth/Yadis/Manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ function getNextService($discover_cb, $fetcher)
413413

414414
list($yadis_url, $services) = call_user_func($discover_cb,
415415
$this->url,
416-
$fetcher);
416+
&$fetcher);
417417

418418
$manager = $this->createManager($services, $yadis_url);
419419
}

0 commit comments

Comments
 (0)