diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-04-14 18:12:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-04-14 18:12:10 +0000 |
commit | b5321aff06d6ea8d730d62aec2ffd8e9271c1ffc (patch) | |
tree | 36c41e35994786456154f9d3bf88c324763aeea4 /daemon/commands.c | |
parent | Adding upstream version 1.33.1. (diff) | |
download | netdata-b5321aff06d6ea8d730d62aec2ffd8e9271c1ffc.tar.xz netdata-b5321aff06d6ea8d730d62aec2ffd8e9271c1ffc.zip |
Adding upstream version 1.34.0.upstream/1.34.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'daemon/commands.c')
-rw-r--r-- | daemon/commands.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/daemon/commands.c b/daemon/commands.c index ddf20fe0b..6efc37c96 100644 --- a/daemon/commands.c +++ b/daemon/commands.c @@ -387,6 +387,7 @@ static void pipe_write_cb(uv_write_t* req, int status) uv_close((uv_handle_t *)client, pipe_close_cb); --clients; + freez(client->data); info("Command Clients = %u\n", clients); } @@ -400,6 +401,10 @@ static inline void add_string_to_command_reply(char *reply_string, unsigned *rep unsigned len; len = strlen(str); + + if (MAX_COMMAND_LENGTH - 1 < len + *reply_string_size) + len = MAX_COMMAND_LENGTH - *reply_string_size - 1; + strncpyz(reply_string + *reply_string_size, str, len); *reply_string_size += len; } @@ -407,7 +412,7 @@ static inline void add_string_to_command_reply(char *reply_string, unsigned *rep static void send_command_reply(struct command_context *cmd_ctx, cmd_status_t status, char *message) { int ret; - char reply_string[MAX_COMMAND_LENGTH] = {'\0', }; + char *reply_string = mallocz(MAX_COMMAND_LENGTH); char exit_status_string[MAX_EXIT_STATUS_LENGTH + 1] = {'\0', }; unsigned reply_string_size = 0; uv_buf_t write_buf; @@ -424,6 +429,7 @@ static void send_command_reply(struct command_context *cmd_ctx, cmd_status_t sta } cmd_ctx->write_req.data = client; + client->data = reply_string; write_buf.base = reply_string; write_buf.len = reply_string_size; ret = uv_write(&cmd_ctx->write_req, (uv_stream_t *)client, &write_buf, 1, pipe_write_cb); |