From 2efb107eb4d4381198de51bd4f092ae1ead02e31 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 8 Dec 2019 23:21:23 +0100 Subject: Fix reading from a null-delimited socket --- src/reader.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/reader.c b/src/reader.c index 68a5f886..ef393ec7 100644 --- a/src/reader.c +++ b/src/reader.c @@ -14,6 +14,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "reader.h" #include "serd_internal.h" #include @@ -343,6 +344,11 @@ serd_reader_read_chunk(SerdReader* reader) st = serd_byte_source_advance(&reader->source); } + if (peek_byte(reader) == 0) { + // Skip leading null byte, for reading from a null-delimited socket + eat_byte_safe(reader, 0); + } + return st ? st : read_statement(reader) ? SERD_SUCCESS : SERD_FAILURE; } -- cgit v1.2.1