StreamDevice: Fix incomplete header reads

The code for reading a StreamDevice message from the streaming agent has
code to handle a situation where you only read a part of the header. If
we've read only a part of the header, we will try to read the remaining
n bytes of the header within a loop until the full header is read.
However, when we try to read the last n bytes, we store it at beginning
of the header struct, which will overwrite the first part of the header.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Jonathon Jongsma 2017-10-31 09:47:46 +01:00 committed by Frediano Ziglio
parent 3165247886
commit 1980dd5dd1

View File

@ -81,7 +81,7 @@ stream_device_read_msg_from_dev(RedCharDevice *self, SpiceCharDeviceInstance *si
/* read header */
while (dev->hdr_pos < sizeof(dev->hdr)) {
n = sif->read(sin, (uint8_t *) &dev->hdr, sizeof(dev->hdr) - dev->hdr_pos);
n = sif->read(sin, (uint8_t *) &dev->hdr + dev->hdr_pos, sizeof(dev->hdr) - dev->hdr_pos);
if (n <= 0) {
return NULL;
}