]> Cypherpunks repositories - gostls13.git/commit
math/big: fix out-of-bounds panic in divRecursive
authorRémy Oudompheng <remyoudompheng@gmail.com>
Wed, 13 Nov 2019 05:53:22 +0000 (06:53 +0100)
committerRobert Griesemer <gri@golang.org>
Wed, 13 Nov 2019 19:15:27 +0000 (19:15 +0000)
commit7ad27481f84dbf325ee348831ed0f95dbf04094e
treef9410e54e46fcbf89c82f30c09917afd76fb8bcb
parente762378c42b786233ea13affa1cc2ee132ceefaf
math/big: fix out-of-bounds panic in divRecursive

The bounds in the last carry branch were wrong as there
is no reason for len(u) >= n+n/2 to always hold true.

We also adjust test to avoid using a remainder of 1
(in which case, the last step of the algorithm computes
(qhatv+1) - qhatv which rarely produces a carry).

Change-Id: I69fbab9c5e19d0db1c087fbfcd5b89352c2d26fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/206839
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/math/big/nat.go
src/math/big/nat_test.go