[Spice-devel] [PATCH spice-server] StreamDevice: Fix incomplete header reads

Frediano Ziglio fziglio at redhat.com
Tue Oct 31 09:20:23 UTC 2017


> 
> 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 at redhat.com>

Acked-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 f87538d49..fc5b50659 100644
> --- a/server/stream-device.c
> +++ b/server/stream-device.c
> @@ -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;
>          }

Frediano


More information about the Spice-devel mailing list