If guest sent an empty data message this was not parsed correctly. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- server/red-stream-device.c | 2 +- server/tests/test-stream-device.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/server/red-stream-device.c b/server/red-stream-device.c index fafcee5ab..d293dc1cc 100644 --- a/server/red-stream-device.c +++ b/server/red-stream-device.c @@ -332,7 +332,7 @@ handle_msg_data(StreamDevice *dev, SpiceCharDeviceInstance *sin) /* read from device */ n = sif->read(sin, dev->msg->buf + dev->msg_pos, dev->hdr.size - dev->msg_pos); if (n <= 0) { - return false; + return dev->msg_pos == dev->hdr.size; } dev->msg_pos += n; diff --git a/server/tests/test-stream-device.c b/server/tests/test-stream-device.c index 00fbc90c7..ae9a78da5 100644 --- a/server/tests/test-stream-device.c +++ b/server/tests/test-stream-device.c @@ -352,8 +352,8 @@ static void test_stream_device_format_after_data(void) basic_event_loop_destroy(); } -// check empty capabilities -static void test_stream_device_empty_capabilities(void) +// check empty message +static void test_stream_device_empty(StreamMsgType msg_type) { uint8_t *p = message; SpiceCoreInterface *core = basic_event_loop_init(); @@ -365,7 +365,7 @@ static void test_stream_device_empty_capabilities(void) message_sizes_end = message_sizes; // add some messages into device buffer - p = add_stream_hdr(p, STREAM_TYPE_CAPABILITIES, 0); + p = add_stream_hdr(p, msg_type, 0); *message_sizes_end = p - message; ++message_sizes_end; p = add_format(p, 640, 480, SPICE_VIDEO_CODEC_TYPE_MJPEG); @@ -396,6 +396,17 @@ static void test_stream_device_empty_capabilities(void) basic_event_loop_destroy(); } +// check empty capabilities +static void test_stream_device_empty_capabilities(void) +{ + test_stream_device_empty(STREAM_TYPE_CAPABILITIES); +} + +// check empty data +static void test_stream_device_empty_data(void) +{ + test_stream_device_empty(STREAM_TYPE_DATA); +} int main(int argc, char *argv[]) { @@ -406,6 +417,7 @@ int main(int argc, char *argv[]) g_test_add_func("/server/stream-device-multiple", test_stream_device_multiple); g_test_add_func("/server/stream-device-format-after-data", test_stream_device_format_after_data); g_test_add_func("/server/stream-device-empty-capabilities", test_stream_device_empty_capabilities); + g_test_add_func("/server/stream-device-empty-data", test_stream_device_empty_data); return g_test_run(); } -- 2.17.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel