mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-06 18:52:33 +00:00
red-stream: Handle reading of 0 bytes in red_stream_async_read
Currently red_stream_async_read cannot handle read of 0 bytes. This would cause a wrong assert in async_read_handler. Fixing the assert would just make the code wrongly detect a disconnection (usually a return of 0 from read is handled that way but happens also if you try to read 0 bytes). Current callers of these function does not pass 0 as size however handling data protocols having data_length+data this can happen and is handled manually in red_sasl_handle_auth_steplen. Avoid needing manually to check for this condition. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe de Dinechin <dinechin@redhat.com>
This commit is contained in:
parent
6174bfe11e
commit
72d095ac8c
@ -550,6 +550,10 @@ void red_stream_async_read(RedStream *stream,
|
||||
AsyncRead *async = &stream->priv->async_read;
|
||||
|
||||
g_return_if_fail(async->now == NULL && async->end == NULL);
|
||||
if (size == 0) {
|
||||
read_done_cb(opaque);
|
||||
return;
|
||||
}
|
||||
async->now = data;
|
||||
async->end = async->now + size;
|
||||
async->done = read_done_cb;
|
||||
@ -904,10 +908,6 @@ static void red_sasl_handle_auth_steplen(void *opaque)
|
||||
return red_sasl_async_result(opaque, auth->mechname ? RED_SASL_ERROR_INVALID_DATA : RED_SASL_ERROR_GENERIC);
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
return red_sasl_handle_auth_step(auth);
|
||||
}
|
||||
|
||||
auth->data = g_realloc(auth->data, len);
|
||||
red_stream_async_read(auth->stream, (uint8_t *)auth->data, len,
|
||||
red_sasl_handle_auth_step, auth);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user