From a25942878d75212e7cbd833f7709899275f597f5 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 15 Mar 2024 14:24:40 +0800 Subject: [PATCH 1/3] fix: sprintf release build report buffer too small --- tools/shell/src/shellEngine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 5c71396ea9..c8125e0c5e 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -1368,7 +1368,7 @@ int32_t shellExecute() { #ifdef WEBSOCKET if (!shell.args.restful && !shell.args.cloud) { #endif -char buf[512] = ""; +char buf[2048] = ""; bool community = shellGetGrantInfo(buf); #ifndef WINDOWS printfIntroduction(community); From 728c3fcfb513612f95f41e5669264412b44c1846 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 15 Mar 2024 14:38:57 +0800 Subject: [PATCH 2/3] fix: sprintf release build report buffer too small --- tools/shell/src/shellEngine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index c8125e0c5e..40d41a560a 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -1152,7 +1152,7 @@ void shellSourceFile(const char *file) { bool shellGetGrantInfo(char* buf) { bool community = true; - char sinfo[1024] = {0}; + char sinfo[128] = {0}; tstrncpy(sinfo, taos_get_server_info(shell.conn), sizeof(sinfo)); strtok(sinfo, "\r\n"); @@ -1368,7 +1368,7 @@ int32_t shellExecute() { #ifdef WEBSOCKET if (!shell.args.restful && !shell.args.cloud) { #endif -char buf[2048] = ""; +char buf[356] = ""; bool community = shellGetGrantInfo(buf); #ifndef WINDOWS printfIntroduction(community); From a81de6e06c83d8f283fd789218b44a53793c735c Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 15 Mar 2024 14:53:13 +0800 Subject: [PATCH 3/3] fix: change stack to malloc reduce memory --- tools/shell/src/shellEngine.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 40d41a560a..8c78a94de6 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -1152,7 +1152,7 @@ void shellSourceFile(const char *file) { bool shellGetGrantInfo(char* buf) { bool community = true; - char sinfo[128] = {0}; + char sinfo[256] = {0}; tstrncpy(sinfo, taos_get_server_info(shell.conn), sizeof(sinfo)); strtok(sinfo, "\r\n"); @@ -1368,7 +1368,7 @@ int32_t shellExecute() { #ifdef WEBSOCKET if (!shell.args.restful && !shell.args.cloud) { #endif -char buf[356] = ""; +char* buf = taosMemoryMalloc(512); bool community = shellGetGrantInfo(buf); #ifndef WINDOWS printfIntroduction(community); @@ -1383,6 +1383,7 @@ bool community = shellGetGrantInfo(buf); if(!community) { printf("%s\n", buf); } +taosMemoryFree(buf); #ifdef WEBSOCKET }