提交 03c3d1aa 编写于 作者: sangshuduo's avatar sangshuduo 提交者: Shuduo Sang

cherry pick with ab6cde02

上级 7f959497
...@@ -87,6 +87,8 @@ extern const int32_t TYPE_BYTES[15]; ...@@ -87,6 +87,8 @@ extern const int32_t TYPE_BYTES[15];
#define TSDB_DEFAULT_PASS "taosdata" #define TSDB_DEFAULT_PASS "taosdata"
#endif #endif
#define SHELL_MAX_PASSWORD_LEN 20
#define TSDB_TRUE 1 #define TSDB_TRUE 1
#define TSDB_FALSE 0 #define TSDB_FALSE 0
#define TSDB_OK 0 #define TSDB_OK 0
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#define MAX_USERNAME_SIZE 64 #define MAX_USERNAME_SIZE 64
#define MAX_DBNAME_SIZE 64 #define MAX_DBNAME_SIZE 64
#define MAX_IP_SIZE 20 #define MAX_IP_SIZE 20
#define MAX_PASSWORD_SIZE 20
#define MAX_HISTORY_SIZE 1000 #define MAX_HISTORY_SIZE 1000
#define MAX_COMMAND_SIZE 1048586 #define MAX_COMMAND_SIZE 1048586
#define HISTORY_FILE ".taos_history" #define HISTORY_FILE ".taos_history"
......
...@@ -66,7 +66,7 @@ void printHelp() { ...@@ -66,7 +66,7 @@ void printHelp() {
char DARWINCLIENT_VERSION[] = "Welcome to the TDengine shell from %s, Client Version:%s\n" char DARWINCLIENT_VERSION[] = "Welcome to the TDengine shell from %s, Client Version:%s\n"
"Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.\n\n"; "Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.\n\n";
char g_password[MAX_PASSWORD_SIZE]; char g_password[SHELL_MAX_PASSWORD_LEN];
void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
wordexp_t full_path; wordexp_t full_path;
...@@ -91,7 +91,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { ...@@ -91,7 +91,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
} }
getchar(); getchar();
} else { } else {
tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(g_password, (char *)(argv[i] + 2), SHELL_MAX_PASSWORD_LEN);
} }
arguments->password = g_password; arguments->password = g_password;
} }
......
...@@ -160,7 +160,7 @@ static struct argp argp = {options, parse_opt, args_doc, doc}; ...@@ -160,7 +160,7 @@ static struct argp argp = {options, parse_opt, args_doc, doc};
char LINUXCLIENT_VERSION[] = "Welcome to the TDengine shell from %s, Client Version:%s\n" char LINUXCLIENT_VERSION[] = "Welcome to the TDengine shell from %s, Client Version:%s\n"
"Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.\n\n"; "Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.\n\n";
char g_password[MAX_PASSWORD_SIZE]; char g_password[SHELL_MAX_PASSWORD_LEN];
static void parse_password( static void parse_password(
int argc, char *argv[], SShellArguments *arguments) { int argc, char *argv[], SShellArguments *arguments) {
...@@ -175,7 +175,7 @@ static void parse_password( ...@@ -175,7 +175,7 @@ static void parse_password(
} }
getchar(); getchar();
} else { } else {
tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(g_password, (char *)(argv[i] + 2), SHELL_MAX_PASSWORD_LEN);
} }
arguments->password = g_password; arguments->password = g_password;
arguments->is_use_passwd = true; arguments->is_use_passwd = true;
......
...@@ -64,7 +64,7 @@ void printHelp() { ...@@ -64,7 +64,7 @@ void printHelp() {
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
char g_password[MAX_PASSWORD_SIZE]; char g_password[SHELL_MAX_PASSWORD_LEN];
void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
...@@ -89,7 +89,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { ...@@ -89,7 +89,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
} }
getchar(); getchar();
} else { } else {
tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(g_password, (char *)(argv[i] + 2), SHELL_MAX_PASSWORD_LEN);
} }
arguments->password = g_password; arguments->password = g_password;
} }
......
...@@ -77,7 +77,6 @@ extern char configDir[]; ...@@ -77,7 +77,6 @@ extern char configDir[];
#define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS) #define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS)
#define MAX_USERNAME_SIZE 64 #define MAX_USERNAME_SIZE 64
#define MAX_PASSWORD_SIZE 16
#define MAX_HOSTNAME_SIZE 253 // https://man7.org/linux/man-pages/man7/hostname.7.html #define MAX_HOSTNAME_SIZE 253 // https://man7.org/linux/man-pages/man7/hostname.7.html
#define MAX_TB_NAME_SIZE 64 #define MAX_TB_NAME_SIZE 64
#define MAX_DATA_SIZE (16*TSDB_MAX_COLUMNS)+20 // max record len: 16*MAX_COLUMNS, timestamp string and ,('') need extra space #define MAX_DATA_SIZE (16*TSDB_MAX_COLUMNS)+20 // max record len: 16*MAX_COLUMNS, timestamp string and ,('') need extra space
...@@ -216,7 +215,7 @@ typedef struct SArguments_S { ...@@ -216,7 +215,7 @@ typedef struct SArguments_S {
uint16_t port; uint16_t port;
uint16_t iface; uint16_t iface;
char * user; char * user;
char password[MAX_PASSWORD_SIZE]; char password[SHELL_MAX_PASSWORD_LEN];
char * database; char * database;
int replica; int replica;
char * tb_prefix; char * tb_prefix;
...@@ -366,7 +365,7 @@ typedef struct SDbs_S { ...@@ -366,7 +365,7 @@ typedef struct SDbs_S {
uint16_t port; uint16_t port;
char user[MAX_USERNAME_SIZE]; char user[MAX_USERNAME_SIZE];
char password[MAX_PASSWORD_SIZE]; char password[SHELL_MAX_PASSWORD_LEN];
char resultFile[MAX_FILE_NAME_LEN]; char resultFile[MAX_FILE_NAME_LEN];
bool use_metric; bool use_metric;
bool insert_only; bool insert_only;
...@@ -432,7 +431,7 @@ typedef struct SQueryMetaInfo_S { ...@@ -432,7 +431,7 @@ typedef struct SQueryMetaInfo_S {
uint16_t port; uint16_t port;
struct sockaddr_in serv_addr; struct sockaddr_in serv_addr;
char user[MAX_USERNAME_SIZE]; char user[MAX_USERNAME_SIZE];
char password[MAX_PASSWORD_SIZE]; char password[SHELL_MAX_PASSWORD_LEN];
char dbName[TSDB_DB_NAME_LEN]; char dbName[TSDB_DB_NAME_LEN];
char queryMode[SMALL_BUFF_LEN]; // taosc, rest char queryMode[SMALL_BUFF_LEN]; // taosc, rest
...@@ -874,7 +873,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -874,7 +873,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} }
taosSetConsoleEcho(true); taosSetConsoleEcho(true);
} else { } else {
tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(arguments->password, (char *)(argv[i] + 2), SHELL_MAX_PASSWORD_LEN);
} }
} else if (strcmp(argv[i], "-o") == 0) { } else if (strcmp(argv[i], "-o") == 0) {
if (argc == i+1) { if (argc == i+1) {
...@@ -3806,9 +3805,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { ...@@ -3806,9 +3805,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
cJSON* password = cJSON_GetObjectItem(root, "password"); cJSON* password = cJSON_GetObjectItem(root, "password");
if (password && password->type == cJSON_String && password->valuestring != NULL) { if (password && password->type == cJSON_String && password->valuestring != NULL) {
tstrncpy(g_Dbs.password, password->valuestring, MAX_PASSWORD_SIZE); tstrncpy(g_Dbs.password, password->valuestring, SHELL_MAX_PASSWORD_LEN);
} else if (!password) { } else if (!password) {
tstrncpy(g_Dbs.password, "taosdata", MAX_PASSWORD_SIZE); tstrncpy(g_Dbs.password, "taosdata", SHELL_MAX_PASSWORD_LEN);
} }
cJSON* resultfile = cJSON_GetObjectItem(root, "result_file"); cJSON* resultfile = cJSON_GetObjectItem(root, "result_file");
...@@ -4544,9 +4543,9 @@ static bool getMetaFromQueryJsonFile(cJSON* root) { ...@@ -4544,9 +4543,9 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
cJSON* password = cJSON_GetObjectItem(root, "password"); cJSON* password = cJSON_GetObjectItem(root, "password");
if (password && password->type == cJSON_String && password->valuestring != NULL) { if (password && password->type == cJSON_String && password->valuestring != NULL) {
tstrncpy(g_queryInfo.password, password->valuestring, MAX_PASSWORD_SIZE); tstrncpy(g_queryInfo.password, password->valuestring, SHELL_MAX_PASSWORD_LEN);
} else if (!password) { } else if (!password) {
tstrncpy(g_queryInfo.password, "taosdata", MAX_PASSWORD_SIZE);; tstrncpy(g_queryInfo.password, "taosdata", SHELL_MAX_PASSWORD_LEN);;
} }
cJSON *answerPrompt = cJSON_GetObjectItem(root, "confirm_parameter_prompt"); // yes, no, cJSON *answerPrompt = cJSON_GetObjectItem(root, "confirm_parameter_prompt"); // yes, no,
...@@ -8888,7 +8887,7 @@ static void initOfInsertMeta() { ...@@ -8888,7 +8887,7 @@ static void initOfInsertMeta() {
tstrncpy(g_Dbs.host, "127.0.0.1", MAX_HOSTNAME_SIZE); tstrncpy(g_Dbs.host, "127.0.0.1", MAX_HOSTNAME_SIZE);
g_Dbs.port = 6030; g_Dbs.port = 6030;
tstrncpy(g_Dbs.user, TSDB_DEFAULT_USER, MAX_USERNAME_SIZE); tstrncpy(g_Dbs.user, TSDB_DEFAULT_USER, MAX_USERNAME_SIZE);
tstrncpy(g_Dbs.password, TSDB_DEFAULT_PASS, MAX_PASSWORD_SIZE); tstrncpy(g_Dbs.password, TSDB_DEFAULT_PASS, SHELL_MAX_PASSWORD_LEN);
g_Dbs.threadCount = 2; g_Dbs.threadCount = 2;
g_Dbs.use_metric = g_args.use_metric; g_Dbs.use_metric = g_args.use_metric;
...@@ -8901,7 +8900,7 @@ static void initOfQueryMeta() { ...@@ -8901,7 +8900,7 @@ static void initOfQueryMeta() {
tstrncpy(g_queryInfo.host, "127.0.0.1", MAX_HOSTNAME_SIZE); tstrncpy(g_queryInfo.host, "127.0.0.1", MAX_HOSTNAME_SIZE);
g_queryInfo.port = 6030; g_queryInfo.port = 6030;
tstrncpy(g_queryInfo.user, TSDB_DEFAULT_USER, MAX_USERNAME_SIZE); tstrncpy(g_queryInfo.user, TSDB_DEFAULT_USER, MAX_USERNAME_SIZE);
tstrncpy(g_queryInfo.password, TSDB_DEFAULT_PASS, MAX_PASSWORD_SIZE); tstrncpy(g_queryInfo.password, TSDB_DEFAULT_PASS, SHELL_MAX_PASSWORD_LEN);
} }
static void setParaFromArg() { static void setParaFromArg() {
...@@ -8915,7 +8914,7 @@ static void setParaFromArg() { ...@@ -8915,7 +8914,7 @@ static void setParaFromArg() {
tstrncpy(g_Dbs.user, g_args.user, MAX_USERNAME_SIZE); tstrncpy(g_Dbs.user, g_args.user, MAX_USERNAME_SIZE);
} }
tstrncpy(g_Dbs.password, g_args.password, MAX_PASSWORD_SIZE); tstrncpy(g_Dbs.password, g_args.password, SHELL_MAX_PASSWORD_LEN);
if (g_args.port) { if (g_args.port) {
g_Dbs.port = g_args.port; g_Dbs.port = g_args.port;
......
...@@ -248,14 +248,12 @@ static struct argp_option options[] = { ...@@ -248,14 +248,12 @@ static struct argp_option options[] = {
{0} {0}
}; };
#define MAX_PASSWORD_SIZE 20
/* Used by main to communicate with parse_opt. */ /* Used by main to communicate with parse_opt. */
typedef struct arguments { typedef struct arguments {
// connection option // connection option
char *host; char *host;
char *user; char *user;
char password[MAX_PASSWORD_SIZE]; char password[SHELL_MAX_PASSWORD_LEN];
uint16_t port; uint16_t port;
char cversion[12]; char cversion[12];
uint16_t mysqlFlag; uint16_t mysqlFlag;
...@@ -567,7 +565,8 @@ static void parse_password( ...@@ -567,7 +565,8 @@ static void parse_password(
} }
taosSetConsoleEcho(true); taosSetConsoleEcho(true);
} else { } else {
tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(arguments->password, (char *)(argv[i] + 2),
SHELL_MAX_PASSWORD_LEN);
} }
argv[i] = ""; argv[i] = "";
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册