diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-07-12 13:24:16 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-07-12 13:24:16 -0400 |
commit | e7213fe2bda8a90b3570e9a41a25a620913b649a (patch) | |
tree | ebbe2d14f853bdedf662dd45533bdc114baa83f1 /src/backend/utils/adt/json.c | |
parent | 4458d6012e7edfc9696e3a3d3c506d4e5887d1cf (diff) | |
download | postgresql-e7213fe2bda8a90b3570e9a41a25a620913b649a.tar.gz postgresql-e7213fe2bda8a90b3570e9a41a25a620913b649a.zip |
Avoid integer overflow while sifting-up a heap in tuplesort.c.
If the number of tuples in the heap exceeds approximately INT_MAX/2,
this loop's calculation "2*i+1" could overflow, resulting in a crash.
Fix it by using unsigned int rather than int for the relevant local
variables; that shouldn't cost anything extra on any popular hardware.
Per bug #14722 from Sergey Koposov.
Original patch by Sergey Koposov, modified by me per a suggestion
from Heikki Linnakangas to use unsigned int not int64.
Back-patch to 9.4, where tuplesort.c grew the ability to sort as many
as INT_MAX tuples in-memory (commit 263865a48).
Discussion: https://postgr.es/m/20170629161637.1478.93109@wrigleys.postgresql.org
Diffstat (limited to 'src/backend/utils/adt/json.c')
0 files changed, 0 insertions, 0 deletions