diff options
Diffstat (limited to '')
-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 ddf20fe0..6efc37c9 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); |