Skip to content

usbredirparser: Fix unserialize on pristine check

Victor Toso requested to merge victortoso/usbredir:test-serialization into main

As mentioned in the bug below, the user is trying to migrate QEMU and it is failing on the unserialization of usbredirparser at the target host. The user does not have USB attached to the VM at all.

I've added a test that shows that serialization is currently broken. It fails at the 'pristine' check in usbredirparser_unserialize().

This check was added with e37d86c2 "Skip empty write buffers when unserializing parser" and restricted further with 186c4c79 "Avoid memory leak from ill-formatted serialization data"

The issue here is that usbredirparser's initialization sets some fields and thus it isn't guaranteed to be pristine.

The parser's basic data is:

field value
write_buf_count 1
write_buf 0xbc03e0
write_buf_total_size 80
data (nil)
header_read 0
type_header_read 0
data_read 0

The current fix is to to ignore write_buf checks as, again, they are not guaranteed to be pristine. usbredirparser library should properly overwrite them when unserializing the data and if there were pending buffers, they should be freed.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2096008

Signed-off-by: Victor Toso victortoso@redhat.com

Edited by Victor Toso

Merge request reports