summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimotej S <6674623+underhood@users.noreply.github.com>2022-03-14 18:14:58 +0100
committerGitHub <noreply@github.com>2022-03-14 18:14:58 +0100
commit7750bb51cd6ae75b64608bb0771365d4dac933c1 (patch)
tree96e75f43b18527d6b1448b09643f01c70985c265
parentbd7bc8b3f14b935731823cc101e1e5ed49c8b5fa (diff)
Fix crash when netdatacli command output too long (#12393)
* check the remaining length
-rw-r--r--daemon/commands.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/daemon/commands.c b/daemon/commands.c
index ddf20fe0ba..9634530e26 100644
--- a/daemon/commands.c
+++ b/daemon/commands.c
@@ -400,6 +400,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;
}