summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2015-08-06 17:25:45 +0000
committerRobert Haas2015-08-06 17:36:10 +0000
commite72f2115ef6d574c64f42ea8b4cbe96accee08b2 (patch)
tree70f9a70176a130cc845f6e7c30706b4d048ba403
parent543e2057fb0e89d64d7250f1afa57ac8305b85a4 (diff)
Fix incorrect calculation in shm_mq_receive.
If some, but not all, of the length word has already been read, and the next attempt to read sees exactly the number of bytes needed to complete the length word, or fewer, then we'll incorrectly read less than all of the available data. Antonin Houska
-rw-r--r--src/backend/storage/ipc/shm_mq.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/storage/ipc/shm_mq.c b/src/backend/storage/ipc/shm_mq.c
index d96627a774e..a49bd17feeb 100644
--- a/src/backend/storage/ipc/shm_mq.c
+++ b/src/backend/storage/ipc/shm_mq.c
@@ -488,7 +488,7 @@ shm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bool nowait)
if (mqh->mqh_partial_bytes + rb > sizeof(Size))
lengthbytes = sizeof(Size) - mqh->mqh_partial_bytes;
else
- lengthbytes = rb - mqh->mqh_partial_bytes;
+ lengthbytes = rb;
memcpy(&mqh->mqh_buffer[mqh->mqh_partial_bytes], rawdata,
lengthbytes);
mqh->mqh_partial_bytes += lengthbytes;