]> granicus.if.org Git - postgresql/commit
Fix possible internal overflow in numeric multiplication.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 21 Sep 2015 16:11:32 +0000 (12:11 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 21 Sep 2015 16:12:16 +0000 (12:12 -0400)
commita89781e34725286b675d41f8dfdfa25ade2a277f
tree6b36f45cc5807f95788e27abed14a1bce43cb34e
parent24aed2124a5273e4cb543b06d4b7bb2c2ad5bf3c
Fix possible internal overflow in numeric multiplication.

mul_var() postpones propagating carries until it risks overflow in its
internal digit array.  However, the logic failed to account for the
possibility of overflow in the carry propagation step, allowing wrong
results to be generated in corner cases.  We must slightly reduce the
when-to-propagate-carries threshold to avoid that.

Discovered and fixed by Dean Rasheed, with small adjustments by me.

This has been wrong since commit d72f6c75038d8d37e64a29a04b911f728044d83b,
so back-patch to all supported branches.
src/backend/utils/adt/numeric.c
src/test/regress/expected/numeric.out
src/test/regress/sql/numeric.sql