vici: Check if header has been received before processing an empty message
authorMartin Willi <martin@revosec.ch>
Wed, 7 May 2014 10:55:30 +0000 (12:55 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 7 May 2014 12:13:39 +0000 (14:13 +0200)
If do_read() returns with EWOULDBLOCK, we must ensure that we actually have
processed the full length header before checking the zero-initialized buffer
length.

src/libcharon/plugins/vici/vici_socket.c

index 05c2374..9167728 100644 (file)
@@ -514,7 +514,8 @@ CALLBACK(on_read, bool,
                {
                        disconnect(this, entry->id);
                }
-               else if (entry->in.buf.len == entry->in.done)
+               else if (entry->in.hdrlen == sizeof(entry->in.hdr) &&
+                                entry->in.buf.len == entry->in.done)
                {
                        array_insert(entry->queue, ARRAY_TAIL, &entry->in.buf);
                        entry->in.buf = chunk_empty;