From 5295b4b25bcdf9c90ca43fb661fe77564b0c670c Mon Sep 17 00:00:00 2001 From: Hui Li Date: Sat, 1 Aug 2020 14:14:08 +0800 Subject: [PATCH 1/3] [modify install.sh] --- packaging/tools/install.sh | 54 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index ce5c052e97..d70c88ca54 100644 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -19,6 +19,8 @@ data_link_dir="/usr/local/taos/data" log_link_dir="/usr/local/taos/log" cfg_install_dir="/etc/taos" +local_fqdn="" +server_port=6030 bin_link_dir="/usr/bin" lib_link_dir="/usr/lib" @@ -211,6 +213,48 @@ function install_header() { ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } +function getLocalFqdn() { + fqdnLine=$(grep fqdn $1 > tmpFqdn.txt) + while read line + do + echo $line + firstChar=${line:0:1} + if [[ "$firstChar" != "#" ]]; then + fqdn=$(echo ${line#*fqdn}) + fqdn=$(echo ${fqdn%%#*}) +# echo "get fqdn from cfg: $fqdn" + break + fi + done tmpServerPort.txt) + while read line + do + echo $line + firstChar=${line:0:1} + if [[ "$firstChar" != "#" ]]; then + port=$(echo ${line#*serverPort}) + port=$(echo ${port%%#*}) +# echo "get serverPort from cfg: $port" + break + fi + done Date: Tue, 4 Aug 2020 18:23:41 +0800 Subject: [PATCH 2/3] [fix coverity] --- src/kit/taosdump/taosdump.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index 993352dc21..8a05c893e8 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -275,7 +275,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { fprintf(stderr, "Invalid path %s\n", arg); return -1; } - strcpy(configDir, full_path.we_wordv[0]); + tstrncpy(configDir, full_path.we_wordv[0], TSDB_FILENAME_LEN); wordfree(&full_path); break; case 'e': @@ -597,7 +597,7 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu numOfThread++; } - memset(tableRecord.name, 0, sizeof(STableRecord)); + memset(&tableRecord, 0, sizeof(STableRecord)); tstrncpy(tableRecord.name, (char *)row[0], fields[0].bytes); tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN); @@ -851,6 +851,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe if (code != 0) { fprintf(stderr, "failed to run command %s\n", tempCommand); free(tempCommand); + free(tbuf); taos_free_result(tmpResult); return -1; } @@ -876,6 +877,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe if (isSuperTable) { free(tempCommand); + free(tbuf); return count; } @@ -891,6 +893,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe if (code != 0) { fprintf(stderr, "failed to run command %s\n", tempCommand); free(tempCommand); + free(tbuf); taos_free_result(tmpResult); return -1; } @@ -901,6 +904,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe if (NULL == row) { fprintf(stderr, " fetch failed to run command %s\n", tempCommand); free(tempCommand); + free(tbuf); taos_free_result(tmpResult); return -1; } @@ -961,6 +965,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe } free(tempCommand); + free(tbuf); return count; } @@ -1835,7 +1840,7 @@ static void taosParseDirectory(const char *directoryName, const char *prefix, ch } int fileNum = 0; - while (fscanf(fp, "%s", fileArray[fileNum++])) { + while (fscanf(fp, "%128s", fileArray[fileNum++])) { if (strcmp(fileArray[fileNum-1], tsDbSqlFile) == 0) { fileNum--; } @@ -1864,7 +1869,7 @@ static void taosCheckTablesSQLFile(const char *directoryName) exit(0); } - while (fscanf(fp, "%s", tsDbSqlFile)) { + while (fscanf(fp, "%128s", tsDbSqlFile)) { break; } @@ -1922,20 +1927,6 @@ static FILE* taosOpenDumpInFile(char *fptr) { char *fname = full_path.we_wordv[0]; - if (access(fname, F_OK) != 0) { - fprintf(stderr, "ERROR: file %s is not exist\n", fptr); - - wordfree(&full_path); - return NULL; - } - - if (access(fname, R_OK) != 0) { - fprintf(stderr, "ERROR: file %s is not readable\n", fptr); - - wordfree(&full_path); - return NULL; - } - FILE *f = fopen(fname, "r"); if (f == NULL) { fprintf(stderr, "ERROR: failed to open file %s\n", fname); From 07c2de638702fe7c4d5aaa683e9cbfbd1e2cdc89 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Tue, 4 Aug 2020 18:29:32 +0800 Subject: [PATCH 3/3] [un] --- packaging/tools/install.sh | 54 ++------------------------------------ 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index d70c88ca54..ce5c052e97 100644 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -19,8 +19,6 @@ data_link_dir="/usr/local/taos/data" log_link_dir="/usr/local/taos/log" cfg_install_dir="/etc/taos" -local_fqdn="" -server_port=6030 bin_link_dir="/usr/bin" lib_link_dir="/usr/lib" @@ -213,48 +211,6 @@ function install_header() { ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } -function getLocalFqdn() { - fqdnLine=$(grep fqdn $1 > tmpFqdn.txt) - while read line - do - echo $line - firstChar=${line:0:1} - if [[ "$firstChar" != "#" ]]; then - fqdn=$(echo ${line#*fqdn}) - fqdn=$(echo ${fqdn%%#*}) -# echo "get fqdn from cfg: $fqdn" - break - fi - done tmpServerPort.txt) - while read line - do - echo $line - firstChar=${line:0:1} - if [[ "$firstChar" != "#" ]]; then - port=$(echo ${line#*serverPort}) - port=$(echo ${port%%#*}) -# echo "get serverPort from cfg: $port" - break - fi - done