mirror of
https://github.com/clearml/dropbear
synced 2025-02-07 13:21:15 +00:00
Turn get_response()'s return type and prompt argument into char *
This commit is contained in:
parent
e5ce3fc51b
commit
59235276ac
@ -31,10 +31,10 @@
|
|||||||
|
|
||||||
#ifdef ENABLE_CLI_INTERACT_AUTH
|
#ifdef ENABLE_CLI_INTERACT_AUTH
|
||||||
|
|
||||||
static unsigned char* get_response(unsigned char* prompt)
|
static char* get_response(char* prompt)
|
||||||
{
|
{
|
||||||
FILE* tty = NULL;
|
FILE* tty = NULL;
|
||||||
unsigned char* response = NULL;
|
char* response = NULL;
|
||||||
/* not a password, but a reasonable limit */
|
/* not a password, but a reasonable limit */
|
||||||
char buf[DROPBEAR_MAX_CLI_PASS];
|
char buf[DROPBEAR_MAX_CLI_PASS];
|
||||||
char* ret = NULL;
|
char* ret = NULL;
|
||||||
@ -50,13 +50,13 @@ static unsigned char* get_response(unsigned char* prompt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
response = (unsigned char*)m_strdup("");
|
response = m_strdup("");
|
||||||
} else {
|
} else {
|
||||||
unsigned int buflen = strlen(buf);
|
unsigned int buflen = strlen(buf);
|
||||||
/* fgets includes newlines */
|
/* fgets includes newlines */
|
||||||
if (buflen > 0 && buf[buflen-1] == '\n')
|
if (buflen > 0 && buf[buflen-1] == '\n')
|
||||||
buf[buflen-1] = '\0';
|
buf[buflen-1] = '\0';
|
||||||
response = (unsigned char*)m_strdup(buf);
|
response = m_strdup(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_burn(buf, sizeof(buf));
|
m_burn(buf, sizeof(buf));
|
||||||
@ -71,9 +71,9 @@ void recv_msg_userauth_info_request() {
|
|||||||
unsigned int num_prompts = 0;
|
unsigned int num_prompts = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
unsigned char *prompt = NULL;
|
char *prompt = NULL;
|
||||||
unsigned int echo = 0;
|
unsigned int echo = 0;
|
||||||
unsigned char *response = NULL;
|
char *response = NULL;
|
||||||
|
|
||||||
TRACE(("enter recv_msg_recv_userauth_info_request"))
|
TRACE(("enter recv_msg_recv_userauth_info_request"))
|
||||||
|
|
||||||
@ -115,13 +115,13 @@ void recv_msg_userauth_info_request() {
|
|||||||
|
|
||||||
for (i = 0; i < num_prompts; i++) {
|
for (i = 0; i < num_prompts; i++) {
|
||||||
unsigned int response_len = 0;
|
unsigned int response_len = 0;
|
||||||
prompt = buf_getstring(ses.payload, NULL);
|
prompt = (char *)buf_getstring(ses.payload, NULL);
|
||||||
cleantext(prompt);
|
cleantext(prompt);
|
||||||
|
|
||||||
echo = buf_getbool(ses.payload);
|
echo = buf_getbool(ses.payload);
|
||||||
|
|
||||||
if (!echo) {
|
if (!echo) {
|
||||||
unsigned char* p = getpass_or_cancel(prompt);
|
char* p = getpass_or_cancel(prompt);
|
||||||
response = m_strdup(p);
|
response = m_strdup(p);
|
||||||
m_burn(p, strlen(p));
|
m_burn(p, strlen(p));
|
||||||
} else {
|
} else {
|
||||||
@ -129,7 +129,7 @@ void recv_msg_userauth_info_request() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
response_len = strlen(response);
|
response_len = strlen(response);
|
||||||
buf_putstring(ses.writepayload, response, response_len);
|
buf_putstring(ses.writepayload, (const unsigned char *)response, response_len);
|
||||||
m_burn(response, response_len);
|
m_burn(response, response_len);
|
||||||
m_free(prompt);
|
m_free(prompt);
|
||||||
m_free(response);
|
m_free(response);
|
||||||
|
Loading…
Reference in New Issue
Block a user