Commit d25d725
committed
Fix GH-16870: gmp_pow(64, 11) throws overflow exception
The current guard to prevent FPEs is way too restrictive; `64 ** 11` is
a perfectly reasonable operation. Instead, we now estimate the number
of bytes of the resulting GMP (assuming that numbers are stored base
256 encoded), and fail if that exceeds a given threshold. The chosen
threshold is somewhat arbitrary.
We also ensure that we do not prematurely convert a given non int base
to an int to avoid overflow which could circumvent our early check.1 parent ff3b4ec commit d25d725
2 files changed
+19
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1350 | 1350 | | |
1351 | 1351 | | |
1352 | 1352 | | |
1353 | | - | |
| 1353 | + | |
1354 | 1354 | | |
1355 | 1355 | | |
1356 | 1356 | | |
1357 | | - | |
| 1357 | + | |
1358 | 1358 | | |
1359 | 1359 | | |
1360 | 1360 | | |
| |||
1364 | 1364 | | |
1365 | 1365 | | |
1366 | 1366 | | |
1367 | | - | |
1368 | | - | |
| 1367 | + | |
1369 | 1368 | | |
1370 | 1369 | | |
1371 | 1370 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments