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
pull/9/head
Robert Haas 11 years ago
parent 680b82eea8
commit 6d9864d900
  1. 2
      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)) if (mqh->mqh_partial_bytes + rb > sizeof(Size))
lengthbytes = sizeof(Size) - mqh->mqh_partial_bytes; lengthbytes = sizeof(Size) - mqh->mqh_partial_bytes;
else else
lengthbytes = rb - mqh->mqh_partial_bytes; lengthbytes = rb;
memcpy(&mqh->mqh_buffer[mqh->mqh_partial_bytes], rawdata, memcpy(&mqh->mqh_buffer[mqh->mqh_partial_bytes], rawdata,
lengthbytes); lengthbytes);
mqh->mqh_partial_bytes += lengthbytes; mqh->mqh_partial_bytes += lengthbytes;

Loading…
Cancel
Save