diff mbox series

[12/13] channel_curl: BUG: endloop if no answer is returned

Message ID 20231120155459.45188-13-stefano.babic@swupdate.org
State Accepted
Headers show
Series Native Docker Support | expand

Commit Message

Stefano Babic Nov. 20, 2023, 3:54 p.m. UTC
If there is no answer and the reply is parsed for a JSON message, system
remains in an endloop because no JSON error is generated for exiting.

Check if there is an answer, and exit from parse_reply in case the
buffer is empty.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
---
 corelib/channel_curl.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index c498c666..422109a0 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -988,6 +988,9 @@  static channel_op_res_t parse_reply(channel_data_t *channel_data, output_data_t
 		return CHANNEL_ENOMEM;
 	}
 
+	if (!chunk->size)
+		return CHANNEL_OK;
+
 	if (channel_data->format == CHANNEL_PARSE_JSON) {
 		assert(channel_data->json_reply == NULL);
 		enum json_tokener_error json_res;