aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2015-08-06 13:25:45 -0400
committerRobert Haas <rhaas@postgresql.org>2015-08-06 13:36:00 -0400
commit6d9864d900e3651413a94e1f86a93f6a03f4dc42 (patch)
tree59422510767ad57fc3619870aa6769a72cfc0adf
parent680b82eea87291e7e14c03a647de654a65617f04 (diff)
downloadpostgresql-6d9864d900e3651413a94e1f86a93f6a03f4dc42.tar.gz
postgresql-6d9864d900e3651413a94e1f86a93f6a03f4dc42.zip
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 126cb0751b3..e765cea5aaa 100644
--- a/src/backend/storage/ipc/shm_mq.c
+++ b/src/backend/storage/ipc/shm_mq.c
@@ -584,7 +584,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;