mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-08 21:14:11 +00:00
smartcard: Fix copying remaining request
Use memmove instead of memcpy as the buffer can overlap if the second request if bigger than the first. "buf_pos" points to the point of the buffer after we read, if we want the first part of the next request is "buf_pos - remaining". Same consideration setting "buf_pos" for the next iteration. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Victor Toso <victortoso@redhat.com>
This commit is contained in:
parent
57d02c2d17
commit
6fa12db104
@ -150,9 +150,9 @@ static RedPipeItem *smartcard_read_msg_from_device(RedCharDevice *self,
|
||||
msg_to_client = smartcard_char_device_on_message_from_device(dev, vheader);
|
||||
remaining = dev->priv->buf_used - sizeof(VSCMsgHeader) - actual_length;
|
||||
if (remaining > 0) {
|
||||
memcpy(dev->priv->buf, dev->priv->buf_pos, remaining);
|
||||
memmove(dev->priv->buf, dev->priv->buf_pos - remaining, remaining);
|
||||
}
|
||||
dev->priv->buf_pos = dev->priv->buf;
|
||||
dev->priv->buf_pos = dev->priv->buf + remaining;
|
||||
dev->priv->buf_used = remaining;
|
||||
if (msg_to_client) {
|
||||
return &msg_to_client->base;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user