From f5333551ed0b2718d8d90eb04119f75a83515e31 Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Tue, 21 Mar 2017 23:06:57 +0800 Subject: [PATCH] Add the missing null terminator to command string --- src/server.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/server.c b/src/server.c index e7a7144..2856db0 100644 --- a/src/server.c +++ b/src/server.c @@ -107,14 +107,15 @@ tty_server_new(int argc, char **argv, int start) { } ts->argv[cmd_argc] = NULL; - ts->command = xmalloc(cmd_len); + ts->command = xmalloc(cmd_len + 1); char *ptr = ts->command; for (int i = 0; i < cmd_argc; i++) { ptr = stpcpy(ptr, ts->argv[i]); if (i != cmd_argc - 1) { - sprintf(ptr++, "%c", ' '); + *ptr++ = ' '; } } + *ptr = '\0'; // null terminator return ts; } -- 2.43.4