From 6b6c9c884e4856f33099e33898252cf4ef3f2c1d Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 28 Oct 2024 16:21:15 +0800 Subject: [PATCH] fix: tstrncpy len must add 1 --- tools/shell/src/shellAuto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 8ad9e9072b..a3093237cb 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -1333,8 +1333,8 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) { // append end ';' char* p = taosMemoryCalloc(strLen + 8, 1); if (p) { - tstrncpy(p, str, strLen); - tstrncpy(p + strLen, ";", 1); + tstrncpy(p, str, strLen + 1); + tstrncpy(p + strLen, ";", 1 + 1); shellInsertStr(cmd, (char*)p, strLen + 1); taosMemoryFree(p); } else {