From 64542e699f3bd47effc0d6e9ee098ad881dad4bc Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 24 May 2019 21:45:59 -0500 Subject: [PATCH] BigInteger: GMP engine didn't always return 1 or -1 --- phpseclib/Math/BigInteger/Engines/GMP.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpseclib/Math/BigInteger/Engines/GMP.php b/phpseclib/Math/BigInteger/Engines/GMP.php index 333829c1..262e55c2 100644 --- a/phpseclib/Math/BigInteger/Engines/GMP.php +++ b/phpseclib/Math/BigInteger/Engines/GMP.php @@ -296,7 +296,14 @@ class GMP extends Engine */ public function compare(GMP $y) { - return gmp_cmp($this->value, $y->value); + $r = gmp_cmp($this->value, $y->value); + if ($r < -1) { + $r = -1; + } + if ($r > 1) { + $r = 1; + } + return $r; } /**