[Spice-devel] [PATCH spice-server v5 7/8] stream-device: Do not read past data message

Frediano Ziglio fziglio at redhat.com
Tue Feb 13 15:54:20 UTC 2018


If data message is followed by another message was theoretically
possible that device looses the sync with the guest.
The actual Qemu and agent implementation avoids it but better
to avoid it.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/stream-device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/stream-device.c b/server/stream-device.c
index 869d8841..d125a877 100644
--- a/server/stream-device.c
+++ b/server/stream-device.c
@@ -257,7 +257,7 @@ handle_msg_data(StreamDevice *dev, SpiceCharDeviceInstance *sin)
 
     while (1) {
         uint8_t buf[16 * 1024];
-        n = sif->read(sin, buf, sizeof(buf));
+        n = sif->read(sin, buf, MIN(sizeof(buf), dev->hdr.size));
         if (n <= 0) {
             break;
         }
-- 
2.14.3



More information about the Spice-devel mailing list