Skip to content

Commit e72f211

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 543e205 commit e72f211

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/storage/ipc/shm_mq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ shm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bool nowait)
488488
if (mqh->mqh_partial_bytes + rb > sizeof(Size))
489489
lengthbytes = sizeof(Size) - mqh->mqh_partial_bytes;
490490
else
491-
lengthbytes = rb - mqh->mqh_partial_bytes;
491+
lengthbytes = rb;
492492
memcpy(&mqh->mqh_buffer[mqh->mqh_partial_bytes], rawdata,
493493
lengthbytes);
494494
mqh->mqh_partial_bytes += lengthbytes;

0 commit comments

Comments
 (0)