[Spice-devel] [PATCH spice-gtk] spice-channel: Adjust endianness in a single place for link message

Christophe Fergeau cfergeau at redhat.com
Wed Nov 21 16:49:24 UTC 2018


Acked-by: Christophe Fergeau <cfergeau at redhat.com>

On Tue, Nov 20, 2018 at 05:36:15PM +0000, Frediano Ziglio wrote:
> Make sure all fields have right endian. "error" field was not adjusted.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  src/spice-channel.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/src/spice-channel.c b/src/spice-channel.c
> index 1b3578cd..1486137e 100644
> --- a/src/spice-channel.c
> +++ b/src/spice-channel.c
> @@ -1913,6 +1913,12 @@ static gboolean spice_channel_recv_link_msg(SpiceChannel *channel)
>                    c->name, __FUNCTION__, rc, c->peer_hdr.size);
>          goto error;
>      }
> +
> +    c->peer_msg->error = GUINT32_FROM_LE(c->peer_msg->error);
> +    c->peer_msg->num_common_caps = GUINT32_FROM_LE(c->peer_msg->num_common_caps);
> +    c->peer_msg->num_channel_caps = GUINT32_FROM_LE(c->peer_msg->num_channel_caps);
> +    c->peer_msg->caps_offset = GUINT32_FROM_LE(c->peer_msg->caps_offset);
> +
>      switch (c->peer_msg->error) {
>      case SPICE_LINK_ERR_OK:
>          /* nothing */
> @@ -1928,8 +1934,8 @@ static gboolean spice_channel_recv_link_msg(SpiceChannel *channel)
>          goto error;
>      }
>  
> -    num_channel_caps = GUINT32_FROM_LE(c->peer_msg->num_channel_caps);
> -    num_common_caps = GUINT32_FROM_LE(c->peer_msg->num_common_caps);
> +    num_channel_caps = c->peer_msg->num_channel_caps;
> +    num_common_caps = c->peer_msg->num_common_caps;
>  
>      num_caps = num_channel_caps + num_common_caps;
>      CHANNEL_DEBUG(channel, "%s: %u caps", __FUNCTION__, num_caps);
> @@ -1937,7 +1943,7 @@ static gboolean spice_channel_recv_link_msg(SpiceChannel *channel)
>      /* see original spice/client code: */
>      /* g_return_if_fail(c->peer_msg + c->peer_msg->caps_offset * sizeof(uint32_t) > c->peer_msg + c->peer_hdr.size); */
>  
> -    caps_src = (uint8_t *)c->peer_msg + GUINT32_FROM_LE(c->peer_msg->caps_offset);
> +    caps_src = (uint8_t *)c->peer_msg + c->peer_msg->caps_offset;
>      CHANNEL_DEBUG(channel, "got remote common caps:");
>      store_caps(caps_src, num_common_caps, c->remote_common_caps);
>  
> -- 
> 2.17.2
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20181121/2cf6bda7/attachment.sig>


More information about the Spice-devel mailing list