mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 20:42:56 +01:00
qemu-usb: only copy data when packet succeeded
In case the packet is erronous the value of 'actual_size' can be invalid and using it may lead to a page-fault due to out-of-bounce access. With this commit access is only performed on successful packets. Fixes #4763.
This commit is contained in:
committed by
Christian Helmuth
parent
e2c334d6e4
commit
8145ff6303
@@ -162,15 +162,16 @@ struct Completion : Usb::Completion
|
||||
|
||||
p->actual_length = 0;
|
||||
|
||||
if (p->pid == USB_TOKEN_IN && actual_size > 0) {
|
||||
if (data) Genode::memcpy(data, content, actual_size);
|
||||
else usb_packet_copy(p, content, actual_size);
|
||||
}
|
||||
if (packet.succeded) {
|
||||
|
||||
p->actual_length = actual_size;
|
||||
if (p->pid == USB_TOKEN_IN && actual_size > 0) {
|
||||
if (data) Genode::memcpy(data, content, actual_size);
|
||||
else usb_packet_copy(p, content, actual_size);
|
||||
}
|
||||
|
||||
if (packet.succeded)
|
||||
p->actual_length = actual_size;
|
||||
p->status = USB_RET_SUCCESS;
|
||||
}
|
||||
else {
|
||||
if (packet.error == Packet_error::STALL_ERROR)
|
||||
p->status = USB_RET_STALL;
|
||||
|
||||
Reference in New Issue
Block a user