cvs: pear /Auth_SASL SASL.php /Auth_SASL/SASL DigestMD5.php

From: Date: Wed, 22 Mar 2006 05:20:11 +0000
Subject: cvs: pear /Auth_SASL SASL.php /Auth_SASL/SASL DigestMD5.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-39235@lists.php.net to get a copy of this message
amistry Wed Mar 22 05:20:11 2006 UTC Modified files: /pear/Auth_SASL SASL.php /pear/Auth_SASL/SASL DigestMD5.php Log: Fix Bug #2143 and Bug #2154. http://cvs.php.net/viewcvs.cgi/pear/Auth_SASL/SASL.php?r1=1.4&r2=1.5&diff_format=u Index: pear/Auth_SASL/SASL.php diff -u pear/Auth_SASL/SASL.php:1.4 pear/Auth_SASL/SASL.php:1.5 --- pear/Auth_SASL/SASL.php:1.4 Fri Feb 21 16:07:17 2003 +++ pear/Auth_SASL/SASL.php Wed Mar 22 05:20:11 2006 @@ -32,7 +32,7 @@ // | Author: Richard Heyes <richard@php.net> | // +-----------------------------------------------------------------------+ // -// $Id: SASL.php,v 1.4 2003/02/21 16:07:17 mj Exp $ +// $Id: SASL.php,v 1.5 2006/03/22 05:20:11 amistry Exp $ /** * Client implementation of various SASL mechanisms @@ -91,7 +91,8 @@ } require_once($filename); - return new $classname(); + $obj = new $classname(); + return $obj; } } http://cvs.php.net/viewcvs.cgi/pear/Auth_SASL/SASL/DigestMD5.php?r1=1.7&r2=1.8&diff_format=u Index: pear/Auth_SASL/SASL/DigestMD5.php diff -u pear/Auth_SASL/SASL/DigestMD5.php:1.7 pear/Auth_SASL/SASL/DigestMD5.php:1.8 --- pear/Auth_SASL/SASL/DigestMD5.php:1.7 Thu Sep 11 18:53:56 2003 +++ pear/Auth_SASL/SASL/DigestMD5.php Wed Mar 22 05:20:11 2006 @@ -32,7 +32,7 @@ // | Author: Richard Heyes <richard@php.net> | // +-----------------------------------------------------------------------+ // -// $Id: DigestMD5.php,v 1.7 2003/09/11 18:53:56 mbretter Exp $ +// $Id: DigestMD5.php,v 1.8 2006/03/22 05:20:11 amistry Exp $ /** * Implmentation of DIGEST-MD5 SASL mechanism @@ -74,7 +74,12 @@ $digest_uri = sprintf('%s/%s', $service, $hostname); $response_value = $this->_getResponseValue($authcid, $pass, $challenge['realm'], $challenge['nonce'], $cnonce, $digest_uri, $authzid); - return sprintf('username="%s",realm="%s"' . $authzid_string . ',nonce="%s",cnonce="%s",nc="00000001",qop=auth,digest-uri="%s",response=%s,%d', $authcid, $challenge['realm'], $challenge['nonce'], $cnonce, $digest_uri, $response_value, $challenge['maxbuf']); + if ($challenge['realm']) { + return sprintf('username="%s",realm="%s"' . $authzid_string . +',nonce="%s",cnonce="%s",nc=00000001,qop=auth,digest-uri="%s",response=%s,maxbuf=%d', $authcid, $challenge['realm'], $challenge['nonce'], $cnonce, $digest_uri, $response_value, $challenge['maxbuf']); + } else { + return sprintf('username="%s"' . $authzid_string . ',nonce="%s",cnonce="%s",nc=00000001,qop=auth,digest-uri="%s",response=%s,maxbuf=%d', $authcid, $challenge['nonce'], $cnonce, $digest_uri, $response_value, $challenge['maxbuf']); + } } else { return PEAR::raiseError('Invalid digest challenge'); } @@ -125,20 +130,19 @@ */ // Realm if (empty($tokens['realm'])) { - $uname = posix_uname(); - $tokens['realm'] = $uname['nodename']; + $tokens['realm'] = ""; } - + // Maxbuf if (empty($tokens['maxbuf'])) { $tokens['maxbuf'] = 65536; } - + // Required: nonce, algorithm if (empty($tokens['nonce']) OR empty($tokens['algorithm'])) { return array(); } - + return $tokens; } @@ -174,11 +178,11 @@ */ function _getCnonce() { - if (file_exists('/dev/urandom')) { - return base64_encode(fread(fopen('/dev/urandom', 'r'), 32)); + if (file_exists('/dev/urandom') && $fd = @fopen('/dev/urandom', 'r')) { + return base64_encode(fread($fd, 32)); - } elseif (file_exists('/dev/random')) { - return base64_encode(fread(fopen('/dev/random', 'r'), 32)); + } elseif (file_exists('/dev/random') && $fd = @fopen('/dev/random', 'r')) { + return base64_encode(fread($fd, 32)); } else { $str = '';

« previous php.pear.cvs (#39235) next »