diff --git a/src/kit/shell/src/shellDarwin.c b/src/kit/shell/src/shellDarwin.c index 49be3917a1663e34a6537026ed130265b935558c..5ca4537aeb334a5939d310ec581dbc8fb296ce76 100644 --- a/src/kit/shell/src/shellDarwin.c +++ b/src/kit/shell/src/shellDarwin.c @@ -86,7 +86,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { printf(DARWINCLIENT_VERSION, tsOsName, taos_get_client_info()); if (strlen(argv[i]) == 2) { printf("Enter password: "); - scanf("%s", g_password); + if (scanf("%s", g_password) > 1) { + fprintf(stderr, "password read error\n"); + } getchar(); } else { tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c index df0166984117d1eb438e4d5872624b65ea7d40c5..d051d3535e3d021c29ae1cc7e92f7666118cec94 100644 --- a/src/kit/shell/src/shellLinux.c +++ b/src/kit/shell/src/shellLinux.c @@ -170,7 +170,9 @@ static void parse_password( printf(LINUXCLIENT_VERSION, tsOsName, taos_get_client_info()); if (strlen(argv[i]) == 2) { printf("Enter password: "); - scanf("%s", g_password); + if (scanf("%20s", g_password) > 1) { + fprintf(stderr, "password reading error\n"); + } getchar(); } else { tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); diff --git a/src/kit/shell/src/shellWindows.c b/src/kit/shell/src/shellWindows.c index 26aa632f04faa8aafa9aaee48e0703921b70210d..bf9afe4b80433e787d907d58eb2d658ef41243c1 100644 --- a/src/kit/shell/src/shellWindows.c +++ b/src/kit/shell/src/shellWindows.c @@ -84,7 +84,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { printf(WINCLIENT_VERSION, tsOsName, taos_get_client_info()); if (strlen(argv[i]) == 2) { printf("Enter password: "); - scanf("%s", g_password); + if (scanf("%s", g_password) > 1) { + fprintf(stderr, "password read error!\n"); + } getchar(); } else { tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index b6c3a0040133769c69ac7e5d8182d325eda4c317..0a2b1d181a62fe760976952449b73015c720e4de 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -863,7 +863,9 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { } else if (strncmp(argv[i], "-p", 2) == 0) { if (strlen(argv[i]) == 2) { printf("Enter password:"); - scanf("%s", arguments->password); + if (scanf("%s", arguments->password) > 1) { + fprintf(stderr, "password read error!\n"); + } } else { tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); } diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index 705e7d361bf52a67f4b6417efac511331c08b803..b7073c28a702da2de2b231d3a0ba082fe57f2c0e 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -561,7 +561,9 @@ static void parse_password( if (strncmp(argv[i], "-p", 2) == 0) { if (strlen(argv[i]) == 2) { printf("Enter password: "); - scanf("%s", arguments->password); + if(scanf("%20s", arguments->password) > 1) { + errorPrint("%s() LN%d, password read error!\n", __func__, __LINE__); + } } else { tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); }