]> 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:04 +0000 (12:12 -0400)
commit844486216eeb5b483c7b45c13b05dce76387c69a
tree9582b2a3d61c20598c5d1f8129936f0e6a7c3d5d
parentc94b65f677875140b019bec1f7dc07bd2e14d45b
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