[Spice-devel] [PATCH spice-server 5/8] smartcard: Use generated parse for messages

Victor Toso victortoso at redhat.com
Tue Oct 8 13:25:50 UTC 2019


Hi,

On Mon, Oct 07, 2019 at 11:39:03AM +0100, Frediano Ziglio wrote:
> The generated code handle possible endianess mismatch and check
> for message format.
> The copy back to "write_buf" allows to use that buffer to send
> data back to device.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

Looks fine as well.
Acked-by: Victor Toso <victortoso at redhat.com>

> ---
>  server/smartcard-channel-client.c | 7 +++----
>  server/smartcard.c                | 1 +
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/server/smartcard-channel-client.c b/server/smartcard-channel-client.c
> index 08af49df..f71b6523 100644
> --- a/server/smartcard-channel-client.c
> +++ b/server/smartcard-channel-client.c
> @@ -274,17 +274,15 @@ bool smartcard_channel_client_handle_message(RedChannelClient *rcc,
>                                               uint32_t size,
>                                               void *message)
>  {
> -    uint8_t *msg = message;
>      VSCMsgHeader* vheader = message;
>      SmartCardChannelClient *scc = SMARTCARD_CHANNEL_CLIENT(rcc);
>  
>      if (type != SPICE_MSGC_SMARTCARD_DATA) {
>          /* Handles seamless migration protocol. Also handles ack's,
>           * spicy sends them while spicec does not */
> -        return red_channel_client_handle_message(rcc, type, size, msg);
> +        return red_channel_client_handle_message(rcc, type, size, message);
>      }
>  
> -    spice_assert(size == vheader->length + sizeof(VSCMsgHeader));
>      switch (vheader->type) {
>          case VSC_ReaderAdd:
>              smartcard_channel_client_add_reader(scc);
> @@ -315,7 +313,8 @@ bool smartcard_channel_client_handle_message(RedChannelClient *rcc,
>                              vheader->reader_id, vheader->type, vheader->length);
>          return FALSE;
>      }
> -    spice_assert(scc->priv->write_buf->buf == msg);
> +    spice_assert(scc->priv->write_buf->buf_size >= size);
> +    memcpy(scc->priv->write_buf->buf, message, size);
>      smartcard_channel_client_write_to_reader(scc);
>  
>      return TRUE;
> diff --git a/server/smartcard.c b/server/smartcard.c
> index 17794b06..3f51f529 100644
> --- a/server/smartcard.c
> +++ b/server/smartcard.c
> @@ -547,6 +547,7 @@ red_smartcard_channel_class_init(RedSmartcardChannelClass *klass)
>  
>      object_class->constructed = red_smartcard_channel_constructed;
>  
> +    channel_class->parser = spice_get_client_channel_parser(SPICE_CHANNEL_SMARTCARD, NULL);
>      channel_class->handle_message = smartcard_channel_client_handle_message,
>  
>      channel_class->send_item = smartcard_channel_send_item;
> -- 
> 2.21.0
> 
> _______________________________________________
> 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/20191008/53f597f7/attachment.sig>


More information about the Spice-devel mailing list