From 19cc43cc1668e179bc4da1782a47d8514e665ff5 Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Sun, 31 Oct 2010 01:05:29 +0000 Subject: [PATCH] - fixed pear.php.net bug # 18015 (thanks, nounours!) git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@129 21d32557-59b3-4da0-833f-c5933fad653e --- phpseclib/Math/BigInteger.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 8752a835..c175ce4e 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -67,7 +67,7 @@ * @author Jim Wigginton * @copyright MMVI Jim Wigginton * @license http://www.gnu.org/licenses/lgpl.txt - * @version $Id: BigInteger.php,v 1.33 2010-03-22 22:32:03 terrafrost Exp $ + * @version $Id: BigInteger.php,v 1.33 2010/03/22 22:32:03 terrafrost Exp $ * @link http://pear.php.net/package/Math_BigInteger */ @@ -596,9 +596,10 @@ class Math_BigInteger { { $hex = $this->toHex($twos_compliment); $bits = ''; - for ($i = 0; $i < strlen($hex); $i+=8) { + for ($i = 0, $end = strlen($hex) & 0xFFFFFFF8; $i < $end; $i+=8) { $bits.= str_pad(decbin(hexdec(substr($hex, $i, 8))), 32, '0', STR_PAD_LEFT); } + $bits.= str_pad(decbin(hexdec(substr($hex, $end))), strlen($hex) & 7, '0', STR_PAD_LEFT); return $this->precision > 0 ? substr($bits, -$this->precision) : ltrim($bits, '0'); }