diff --git a/libfreerdp-utils/args.c b/libfreerdp-utils/args.c index 74b53ae61..9ac26deac 100644 --- a/libfreerdp-utils/args.c +++ b/libfreerdp-utils/args.c @@ -726,7 +726,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, char input[512]; input[0] = '\0'; printf("username: "); - if (scanf("%511s", input) > 0) + if (scanf("%511s%*c", input) > 0) { settings->username = xstrdup(input); } @@ -736,11 +736,13 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, { settings->password = xmalloc(512 * sizeof(char)); if (isatty(STDIN_FILENO)) + { freerdp_passphrase_read("password: ", settings->password, 512, settings->from_stdin); + } else { printf("password: "); - if (scanf("%511s", settings->password) <= 0) + if (scanf("%511s%*c", settings->password) <= 0) { free(settings->password); settings->password = NULL; @@ -753,7 +755,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, char input[512]; input[0] = '\0'; printf("domain (control-D to skip): "); - if (scanf("%511s", input) > 0) + if (scanf("%511s%*c", input) > 0) { /* Try to catch the cases where the string is NULL-ish right at the get go */ @@ -762,6 +764,11 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, settings->domain = xstrdup(input); } } + if (feof(stdin)) + { + printf("\n"); + clearerr(stdin); + } } /* hostname */ if (NULL == settings->hostname) @@ -769,7 +776,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, char input[512]; input[0] = '\0'; printf("hostname: "); - if (scanf("%511s", input) > 0) + if (scanf("%511s%*c", input) > 0) { freerdp_parse_hostname(settings, input); }