Avoid invalid alloc size error in shm_mq
authorPeter Eisentraut <peter@eisentraut.org>
Mon, 19 Oct 2020 06:52:25 +0000 (08:52 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 20 Oct 2020 15:22:41 +0000 (17:22 +0200)
commitd27c18d26f00fc13401931fe9deb5012610faf89
tree4814b04f2b820f4f1da1545772471d69385641af
parentda129a04a6dea8c30eec2477c08d17736c92d431
Avoid invalid alloc size error in shm_mq

In shm_mq_receive(), a huge payload could trigger an unjustified
"invalid memory alloc request size" error due to the way the buffer
size is increased.

Add error checks (documenting the upper limit) and avoid the error by
limiting the allocation size to MaxAllocSize.

Author: Markus Wanner <markus.wanner@2ndquadrant.com>
Discussion: http://www.postgresql.org/message-id/flat/3bb363e7-ac04-0ac4-9fe8-db1148755bfa%402ndquadrant.com
src/backend/storage/ipc/shm_mq.c