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

[TD-6473]<fix>: taosdump verify input arguments. (#8048)

上级 8da7318a
...@@ -493,23 +493,38 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { ...@@ -493,23 +493,38 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
errorPrint("Invalid path %s\n", arg); errorPrint("Invalid path %s\n", arg);
return -1; return -1;
} }
if (full_path.we_wordv[0]) {
tstrncpy(g_args.outpath, full_path.we_wordv[0], tstrncpy(g_args.outpath, full_path.we_wordv[0],
MAX_FILE_NAME_LEN); MAX_FILE_NAME_LEN);
wordfree(&full_path); wordfree(&full_path);
} else {
errorPrintReqArg3("taosdump", "-o or --outpath");
exit(EXIT_FAILURE);
}
break; break;
case 'g': case 'g':
g_args.debug_print = true; g_args.debug_print = true;
break; break;
case 'i': case 'i':
g_args.isDumpIn = true; g_args.isDumpIn = true;
if (wordexp(arg, &full_path, 0) != 0) { if (wordexp(arg, &full_path, 0) != 0) {
errorPrint("Invalid path %s\n", arg); errorPrint("Invalid path %s\n", arg);
return -1; return -1;
} }
if (full_path.we_wordv[0]) {
tstrncpy(g_args.inpath, full_path.we_wordv[0], tstrncpy(g_args.inpath, full_path.we_wordv[0],
MAX_FILE_NAME_LEN); MAX_FILE_NAME_LEN);
wordfree(&full_path); wordfree(&full_path);
} else {
errorPrintReqArg3("taosdump", "-i or --inpath");
exit(EXIT_FAILURE);
}
break; break;
case 'r': case 'r':
g_args.resultFile = arg; g_args.resultFile = arg;
break; break;
...@@ -2776,7 +2791,7 @@ int main(int argc, char *argv[]) { ...@@ -2776,7 +2791,7 @@ int main(int argc, char *argv[]) {
} }
printf("====== arguments config ======\n"); printf("====== arguments config ======\n");
{
printf("host: %s\n", g_args.host); printf("host: %s\n", g_args.host);
printf("user: %s\n", g_args.user); printf("user: %s\n", g_args.user);
printf("password: %s\n", g_args.password); printf("password: %s\n", g_args.password);
...@@ -2810,7 +2825,7 @@ int main(int argc, char *argv[]) { ...@@ -2810,7 +2825,7 @@ int main(int argc, char *argv[]) {
for (int32_t i = 0; i < g_args.arg_list_len; i++) { for (int32_t i = 0; i < g_args.arg_list_len; i++) {
printf("arg_list[%d]: %s\n", i, g_args.arg_list[i]); printf("arg_list[%d]: %s\n", i, g_args.arg_list[i]);
} }
}
printf("==============================\n"); printf("==============================\n");
if (checkParam(&g_args) < 0) { if (checkParam(&g_args) < 0) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -2824,7 +2839,7 @@ int main(int argc, char *argv[]) { ...@@ -2824,7 +2839,7 @@ int main(int argc, char *argv[]) {
fprintf(g_fpOfResult, "#############################################################################\n"); fprintf(g_fpOfResult, "#############################################################################\n");
fprintf(g_fpOfResult, "============================== arguments config =============================\n"); fprintf(g_fpOfResult, "============================== arguments config =============================\n");
{
fprintf(g_fpOfResult, "host: %s\n", g_args.host); fprintf(g_fpOfResult, "host: %s\n", g_args.host);
fprintf(g_fpOfResult, "user: %s\n", g_args.user); fprintf(g_fpOfResult, "user: %s\n", g_args.user);
fprintf(g_fpOfResult, "password: %s\n", g_args.password); fprintf(g_fpOfResult, "password: %s\n", g_args.password);
...@@ -2857,7 +2872,6 @@ int main(int argc, char *argv[]) { ...@@ -2857,7 +2872,6 @@ int main(int argc, char *argv[]) {
for (int32_t i = 0; i < g_args.arg_list_len; i++) { for (int32_t i = 0; i < g_args.arg_list_len; i++) {
fprintf(g_fpOfResult, "arg_list[%d]: %s\n", i, g_args.arg_list[i]); fprintf(g_fpOfResult, "arg_list[%d]: %s\n", i, g_args.arg_list[i]);
} }
}
g_numOfCores = (int32_t)sysconf(_SC_NPROCESSORS_ONLN); g_numOfCores = (int32_t)sysconf(_SC_NPROCESSORS_ONLN);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册