| From: | David Rowley <drowley(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix missing money overflow checks for INT64_MIN / -1 |
| Date: | 2026-08-04 06:00:43 |
| Message-ID: | E1wr8Ch-000000007RL-1lkZ@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix missing money overflow checks for INT64_MIN / -1
Similar to what 1f7cb5c30 did for the INT types, protect against
overflow when dividing the lowest possible money value by -1. This
cannot be represented on a two's complement machine.
Without this check, the result depends on the machine, and in the worst
case, could result in a crash. With the fix installed, this will now
result in:
ERROR: money out of range
Bug: #19585
Author: Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>
Reported-by: Michael Malis <malis(at)pgrust(dot)com>
Reviewed-by: Tristan Partin <tristan(at)partin(dot)io>
Reviewed-by: Rafia Sabih <rafia(dot)pghackers(at)gmail(dot)com>
Discussion: https://postgr.es/m/19586-bb603bf5ad9934dd%40postgresql.org
Discussion: https://postgr.es/m/CAB8bMisnXJVXte6s3kUOpuuAY9%3D9kehG6MMX-%2BTQoFsSGan22Q%40mail.gmail.com
Backpatch-through: 14
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/6298a41b4e34773dbc0c50c26de825a4efe31f07
Modified Files
--------------
src/backend/utils/adt/cash.c | 16 ++++++++++++++++
src/test/regress/expected/money.out | 8 ++++++++
src/test/regress/sql/money.sql | 4 ++++
3 files changed, 28 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Rowley | 2026-08-04 06:01:03 | pgsql: Fix missing money overflow checks for INT64_MIN / -1 |
| Previous Message | David Rowley | 2026-08-04 06:00:20 | pgsql: Fix missing money overflow checks for INT64_MIN / -1 |