diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index da79b031..1807e4aa 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -2727,7 +2727,14 @@ class Math_BigInteger { switch (MATH_BIGINTEGER_MODE) { case MATH_BIGINTEGER_MODE_GMP: - 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; case MATH_BIGINTEGER_MODE_BCMATH: return bccomp($this->value, $y->value, 0); }