From 70393442a364ecad325ca2024530074bb6d4f0be Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 3 Oct 2014 09:10:05 +1000 Subject: [PATCH] Zero bufofs in connector loop for completeness and make sure to retry if there is more data to read --- src/connector.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/connector.c b/src/connector.c index bc9e2232..4090a567 100644 --- a/src/connector.c +++ b/src/connector.c @@ -237,9 +237,10 @@ reparse: return; } memcpy(msg, client->buf, buflen); - msg[buflen] = 0; + msg[buflen] = '\0'; client->bufofs -= buflen; memmove(client->buf, client->buf + buflen, client->bufofs); + client->buf[client->bufofs] = '\0'; if (!(val = json_loads(msg, 0, NULL))) { char *buf = strdup("Invalid JSON, disconnecting\n"); @@ -270,6 +271,8 @@ reparse: if (client->bufofs) goto reparse; + if (moredata) + goto retry; } /* Waits on fds ready to read on from the list stored in conn_instance and