Skip to content

Commit df0a67f

Browse files
committed
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
1 parent 0e141c0 commit df0a67f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/storage/ipc/shm_mq.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ shm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bool nowait)
584584
if (mqh->mqh_partial_bytes + rb > sizeof(Size))
585585
lengthbytes = sizeof(Size) - mqh->mqh_partial_bytes;
586586
else
587-
lengthbytes = rb - mqh->mqh_partial_bytes;
587+
lengthbytes = rb;
588588
memcpy(&mqh->mqh_buffer[mqh->mqh_partial_bytes], rawdata,
589589
lengthbytes);
590590
mqh->mqh_partial_bytes += lengthbytes;

0 commit comments

Comments
 (0)