[utils,passphrase] format & clean code

This commit is contained in:
akallabeth
2024-08-28 10:07:36 +02:00
parent 3f0000df0f
commit 396b3b51b4

View File

@@ -128,7 +128,7 @@ static void replace_char(char* buffer, size_t buffer_len, const char* toreplace)
}
char* freerdp_passphrase_read_tty(rdpContext* context, const char* prompt, char* buf, size_t bufsiz,
int from_stdin)
int from_stdin)
{
BOOL terminal_needs_reset = FALSE;
char term_name[L_ctermid] = { 0 };
@@ -213,24 +213,21 @@ error:
}
}
char* freerdp_passphrase_read_askpass(const char* prompt, char* buf, size_t bufsiz,
char const *askpass_env)
char const* askpass_env)
{
char command[4096] = { 0 };
FILE *askproc;
int status;
sprintf_s(command, sizeof(command), "%s 'FreeRDP authentication\n%s'",
askpass_env, prompt);
askproc = popen(command, "r");
(void)sprintf_s(command, sizeof(command), "%s 'FreeRDP authentication\n%s'", askpass_env,
prompt);
FILE* askproc = popen(command, "r");
if (!askproc)
return NULL;
if (fgets(buf, bufsiz, askproc) != NULL)
buf[strcspn(buf, "\r\n")] = '\0';
else
buf = NULL;
status = pclose(askproc);
const int status = pclose(askproc);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
buf = NULL;
@@ -240,7 +237,7 @@ char* freerdp_passphrase_read_askpass(const char* prompt, char* buf, size_t bufs
char* freerdp_passphrase_read(rdpContext* context, const char* prompt, char* buf, size_t bufsiz,
int from_stdin)
{
char const *askpass_env = getenv("FREERDP_ASKPASS");
char const* askpass_env = getenv("FREERDP_ASKPASS");
if (!askpass_env)
askpass_env = getenv("SSH_ASKPASS");