From 8d53e9f3c6001dcb2865f6e894da5b54e1418f88 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 4 Jul 2019 10:40:06 +0200 Subject: New upstream version 18.11.2 Change-Id: I23eb4f9179abf1f9c659891f8fddb27ee68ad26b Signed-off-by: Christian Ehrhardt --- test/test/commands.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/test/commands.c') diff --git a/test/test/commands.c b/test/test/commands.c index 94fbc310..8d5a03a9 100644 --- a/test/test/commands.c +++ b/test/test/commands.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "test.h" @@ -365,23 +366,22 @@ cmdline_parse_ctx_t main_ctx[] = { int commands_init(void) { struct test_command *t; - char *commands, *ptr; + char *commands; int commands_len = 0; TAILQ_FOREACH(t, &commands_list, next) { commands_len += strlen(t->command) + 1; } - commands = malloc(commands_len + 1); + commands = (char *)calloc(commands_len, sizeof(char)); if (!commands) return -1; - ptr = commands; TAILQ_FOREACH(t, &commands_list, next) { - ptr += sprintf(ptr, "%s#", t->command); + strlcat(commands, t->command, commands_len); + if (TAILQ_NEXT(t, next) != NULL) + strlcat(commands, "#", commands_len); } - ptr--; - ptr[0] = '\0'; cmd_autotest_autotest.string_data.str = commands; return 0; -- cgit 1.2.3-korg