Improve error message for client receive buffer overflow

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
pull/203/head
Jim Ramsay 2022-12-21 09:07:22 -05:00
parent 3e5d6ea8eb
commit 5d443bfa60
1 changed files with 7 additions and 2 deletions

View File

@ -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) {
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;