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@xxxxxxxxxx> --- 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@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel