未验证 提交 250b27d1 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

Hotfix/sangshuduo/td 3197 fix taosdemo coverity scan (#6003)

* [TD-3197] <fix>: fix taosdemo coverity scan issues.

* [TD-3197] <fix>: fix taosdemo coverity scan issue.

fix subscribeTest pids uninitialized.

* [TD-3197] <fix>: fix taosdemo coverity scan issues.

* [TD-3197] <fix>: fix coverity scan issues.

check super tbl info pointer.

* [TD-3197] <fix>: fix coverity scan issues.

move sub tbl query thread join into loop

* [TD-3197] <fix>: fix coverity scan issues.

remove unused variable

* [TD-3197] <fix>: fix coverity scan issues.

use more secure random library

* [TD-3197] <fix>: fix coverity scan issues.

use strncpy for more safe

* [TD-3197] <fix>: fix taosdemo coverity scan issue.

replace arc4random with rand().

* [TD-3197] <fix>: fix coverity scan issues.

check stb info pointer for start time

* [TD-3197] <fix>: fix coverity scan issues.

fix strcpy vulnerability

* [TD-3197] <fix>: fix taosdemo coverity scan issue.

modify taosdemoTest2. try to check database continously.

* [TD-3197] <fix>: taosdemo coverity scan issues.

* [TD-3197] <fix>: fix memory leak when parsing arguments.

* [TD-3197] <fix>: fix cmake strip arguments.

* [TD-3197] <fix>: taosdemo coverity scan.

fix cmake string manipulation.

* [TD-3197]<fix>: taosdemo coverity scan issue.

configDir buffer overwrite.

* [TD-3197]<fix>: coverity scan issue.

taosdump argument validation.

* [TD-3197]<fix>: taosdemo and taosdump coverity scan issues.
Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 cf9693c5
...@@ -725,7 +725,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -725,7 +725,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrint("%s", "\n\t-c need a valid path following!\n"); errorPrint("%s", "\n\t-c need a valid path following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
tstrncpy(configDir, argv[++i], MAX_FILE_NAME_LEN); tstrncpy(configDir, argv[++i], TSDB_FILENAME_LEN);
} else if (strcmp(argv[i], "-h") == 0) { } else if (strcmp(argv[i], "-h") == 0) {
if (argc == i+1) { if (argc == i+1) {
...@@ -967,9 +967,9 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -967,9 +967,9 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} }
} else if (strcmp(argv[i], "-D") == 0) { } else if (strcmp(argv[i], "-D") == 0) {
arguments->method_of_delete = atoi(argv[++i]); arguments->method_of_delete = atoi(argv[++i]);
if (arguments->method_of_delete < 0 if (arguments->method_of_delete > 3) {
|| arguments->method_of_delete > 3) { errorPrint("%s", "\n\t-D need a valud (0~3) number following!\n");
arguments->method_of_delete = 0; exit(EXIT_FAILURE);
} }
} else if ((strcmp(argv[i], "--version") == 0) || } else if ((strcmp(argv[i], "--version") == 0) ||
(strcmp(argv[i], "-V") == 0)){ (strcmp(argv[i], "-V") == 0)){
...@@ -1372,7 +1372,7 @@ static int printfInsertMeta() { ...@@ -1372,7 +1372,7 @@ static int printfInsertMeta() {
printf(" childTblLimit: \033[33m%"PRId64"\033[0m\n", printf(" childTblLimit: \033[33m%"PRId64"\033[0m\n",
g_Dbs.db[i].superTbls[j].childTblLimit); g_Dbs.db[i].superTbls[j].childTblLimit);
} }
if (g_Dbs.db[i].superTbls[j].childTblOffset >= 0) { if (g_Dbs.db[i].superTbls[j].childTblOffset > 0) {
printf(" childTblOffset: \033[33m%"PRIu64"\033[0m\n", printf(" childTblOffset: \033[33m%"PRIu64"\033[0m\n",
g_Dbs.db[i].superTbls[j].childTblOffset); g_Dbs.db[i].superTbls[j].childTblOffset);
} }
...@@ -4706,8 +4706,7 @@ static void getTableName(char *pTblName, threadInfo* pThreadInfo, uint64_t table ...@@ -4706,8 +4706,7 @@ static void getTableName(char *pTblName, threadInfo* pThreadInfo, uint64_t table
{ {
SSuperTable* superTblInfo = pThreadInfo->superTblInfo; SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
if (superTblInfo) { if (superTblInfo) {
if ((superTblInfo->childTblOffset >= 0) if (superTblInfo->childTblLimit > 0) {
&& (superTblInfo->childTblLimit > 0)) {
snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s", snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s",
superTblInfo->childTblName + superTblInfo->childTblName +
(tableSeq - superTblInfo->childTblOffset) * TSDB_TABLE_NAME_LEN); (tableSeq - superTblInfo->childTblOffset) * TSDB_TABLE_NAME_LEN);
...@@ -5611,8 +5610,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -5611,8 +5610,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
printf("WARNING: offset and limit will not be used since the child tables not exists!\n"); printf("WARNING: offset and limit will not be used since the child tables not exists!\n");
} }
if ((superTblInfo->childTblExists == TBL_ALREADY_EXISTS) if (superTblInfo->childTblExists == TBL_ALREADY_EXISTS) {
&& (superTblInfo->childTblOffset >= 0)) {
if ((superTblInfo->childTblLimit < 0) if ((superTblInfo->childTblLimit < 0)
|| ((superTblInfo->childTblOffset + superTblInfo->childTblLimit) || ((superTblInfo->childTblOffset + superTblInfo->childTblLimit)
> (superTblInfo->childTblCount))) { > (superTblInfo->childTblCount))) {
......
...@@ -525,7 +525,7 @@ int main(int argc, char *argv[]) { ...@@ -525,7 +525,7 @@ int main(int argc, char *argv[]) {
/* Parse our arguments; every option seen by parse_opt will be /* Parse our arguments; every option seen by parse_opt will be
reflected in arguments. */ reflected in arguments. */
if (argc > 1) if (argc > 2)
parse_args(argc, argv, &g_args); parse_args(argc, argv, &g_args);
argp_parse(&argp, argc, argv, 0, 0, &g_args); argp_parse(&argp, argc, argv, 0, 0, &g_args);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册