Avoid invalid alloc size error in shm_mq

Peter Eisentraut <peter@eisentraut.org>

Commit: bd0677bb8a54683b05b75fc242bd5c757ce5edd8
Author: Peter Eisentraut <peter@eisentraut.org>
Date: 2020-10-20T12:31:52Z
Releases: 12.5
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: https://www.postgresql.org/message-id/flat/3bb363e7-ac04-0ac4-9fe8-db1148755bfa%402ndquadrant.com

Files

PathChange+/−
src/backend/storage/ipc/shm_mq.c modified +24 −0

Discussion