From 4af76d20cafcd456bf3ce0fcb17b25a888c45160 Mon Sep 17 00:00:00 2001 From: Thomas <thomas@roundcube.net> Date: Mon, 21 Oct 2013 15:14:46 -0400 Subject: [PATCH] Bump version --- program/lib/Auth/SASL/DigestMD5.php | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-) diff --git a/program/lib/Auth/SASL/DigestMD5.php b/program/lib/Auth/SASL/DigestMD5.php index dcd9910..07007b7 100644 --- a/program/lib/Auth/SASL/DigestMD5.php +++ b/program/lib/Auth/SASL/DigestMD5.php @@ -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,15 +178,14 @@ */ 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 = ''; - mt_srand((double)microtime()*10000000); for ($i=0; $i<32; $i++) { $str .= chr(mt_rand(0, 255)); } -- Gitblit v1.9.1