[Spice-commits] server/red-stream.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Tue Jan 30 15:07:18 UTC 2018


 server/red-stream.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 72d095ac8cf5d287a72516de91cf5f3614cc1767
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Jan 16 14:01:34 2018 +0000

    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 at redhat.com>
    Acked-by: Christophe de Dinechin <dinechin at redhat.com>

diff --git a/server/red-stream.c b/server/red-stream.c
index 8f2c9d32..bdc8bc1f 100644
--- a/server/red-stream.c
+++ b/server/red-stream.c
@@ -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);


More information about the Spice-commits mailing list