From 5d443bfa603d4a1bb728089342a40f15dd776418 Mon Sep 17 00:00:00 2001 From: Jim Ramsay Date: Wed, 21 Dec 2022 09:07:22 -0500 Subject: [PATCH] Improve error message for client receive buffer overflow Signed-off-by: Jim Ramsay --- src/ctl-client.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ctl-client.c b/src/ctl-client.c index 544a588..3d6847f 100644 --- a/src/ctl-client.c +++ b/src/ctl-client.c @@ -222,8 +222,13 @@ static json_t* json_from_buffer(struct ctl_client* self) if (root) { advance_read_buffer(&self->read_buffer, &self->read_len, err.position); } else if (json_error_code(&err) == json_error_premature_end_of_input) { - DEBUG("Awaiting more data"); - errno = ENODATA; + if (self->read_len == sizeof(self->read_buffer)) { + WARN("Response message is too long"); + errno = EMSGSIZE; + } else { + DEBUG("Awaiting more data"); + errno = ENODATA; + } } else { WARN("Json parsing failed: %s", err.text); errno = EINVAL;