From e9d99a66834c5aeb79497af354e4ddd3db6454ab Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 26 May 2019 11:14:58 -0500 Subject: [PATCH 1/2] Tests/BigInteger: add unit test for 0 loaded as base-10 --- tests/Unit/Math/BigInteger/TestCase.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/Unit/Math/BigInteger/TestCase.php b/tests/Unit/Math/BigInteger/TestCase.php index e7f7bbeb..821e4280 100644 --- a/tests/Unit/Math/BigInteger/TestCase.php +++ b/tests/Unit/Math/BigInteger/TestCase.php @@ -406,4 +406,10 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase $temp = $this->getInstance(48); $this->assertSame($temp->toHex(true), '30'); } + + public function testZeroBase10() + { + $temp = $this->getInstance('00'); + $this->assertSame($temp->toString(), '0'); + } } From 9c67616f1eba5ed0f7eb128095542811b0f42e3b Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 26 May 2019 11:41:03 -0500 Subject: [PATCH 2/2] BigInteger: new BigInteger('00') caused issues with GMP --- phpseclib/Math/BigInteger.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 9082ad5f..da79b031 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -441,6 +441,9 @@ class Math_BigInteger // (?<=^|-)0*: find any 0's that are preceded by the start of the string or by a - (ie. octals) // [^-0-9].*: find any non-numeric characters and then any characters that follow that $x = preg_replace('#(?