提交 8959897d 编写于 作者: sangshuduo's avatar sangshuduo

determine scanf return value.

上级 85961d0d
...@@ -86,7 +86,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { ...@@ -86,7 +86,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
printf(DARWINCLIENT_VERSION, tsOsName, taos_get_client_info()); printf(DARWINCLIENT_VERSION, tsOsName, taos_get_client_info());
if (strlen(argv[i]) == 2) { if (strlen(argv[i]) == 2) {
printf("Enter password: "); printf("Enter password: ");
scanf("%s", g_password); if (scanf("%s", g_password) > 1) {
fprintf(stderr, "password read error\n");
}
getchar(); getchar();
} else { } else {
tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE);
......
...@@ -170,7 +170,9 @@ static void parse_password( ...@@ -170,7 +170,9 @@ static void parse_password(
printf(LINUXCLIENT_VERSION, tsOsName, taos_get_client_info()); printf(LINUXCLIENT_VERSION, tsOsName, taos_get_client_info());
if (strlen(argv[i]) == 2) { if (strlen(argv[i]) == 2) {
printf("Enter password: "); printf("Enter password: ");
scanf("%s", g_password); if (scanf("%20s", g_password) > 1) {
fprintf(stderr, "password reading error\n");
}
getchar(); getchar();
} else { } else {
tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE);
......
...@@ -84,7 +84,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { ...@@ -84,7 +84,9 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
printf(WINCLIENT_VERSION, tsOsName, taos_get_client_info()); printf(WINCLIENT_VERSION, tsOsName, taos_get_client_info());
if (strlen(argv[i]) == 2) { if (strlen(argv[i]) == 2) {
printf("Enter password: "); printf("Enter password: ");
scanf("%s", g_password); if (scanf("%s", g_password) > 1) {
fprintf(stderr, "password read error!\n");
}
getchar(); getchar();
} else { } else {
tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE);
......
...@@ -863,7 +863,9 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -863,7 +863,9 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} else if (strncmp(argv[i], "-p", 2) == 0) { } else if (strncmp(argv[i], "-p", 2) == 0) {
if (strlen(argv[i]) == 2) { if (strlen(argv[i]) == 2) {
printf("Enter password:"); printf("Enter password:");
scanf("%s", arguments->password); if (scanf("%s", arguments->password) > 1) {
fprintf(stderr, "password read error!\n");
}
} else { } else {
tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE);
} }
......
...@@ -561,7 +561,9 @@ static void parse_password( ...@@ -561,7 +561,9 @@ static void parse_password(
if (strncmp(argv[i], "-p", 2) == 0) { if (strncmp(argv[i], "-p", 2) == 0) {
if (strlen(argv[i]) == 2) { if (strlen(argv[i]) == 2) {
printf("Enter password: "); printf("Enter password: ");
scanf("%s", arguments->password); if(scanf("%20s", arguments->password) > 1) {
errorPrint("%s() LN%d, password read error!\n", __func__, __LINE__);
}
} else { } else {
tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册