]> 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:11:58 +0000 (12:11 -0400)
commit8b75e489a48cc7ad61cd723180652e6fc1977911
treeb405e6565e22bf6bfe23cacbd5807d377face7cb
parentea218a2ba70d9f11f5a271728de26450a9b23d6c
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