From: Shuanglei Tao Date: Tue, 21 Mar 2017 15:06:57 +0000 (+0800) Subject: Add the missing null terminator to command string X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=f5333551ed0b2718d8d90eb04119f75a83515e31;p=ttyd.git Add the missing null terminator to command string --- 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; }