diff options
author | marha <marha@users.sourceforge.net> | 2012-01-24 16:46:55 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-01-24 16:46:55 +0100 |
commit | 6039fd0faf73c9d6c5b2abf9d824734218ec5eee (patch) | |
tree | 88f66f9d7c4763f206de6043ef45c63b94472690 /tools/plink/wincons.c | |
parent | b683b8f5675e280a6dd4ab82d6b9394182798b55 (diff) | |
download | vcxsrv-6039fd0faf73c9d6c5b2abf9d824734218ec5eee.tar.gz vcxsrv-6039fd0faf73c9d6c5b2abf9d824734218ec5eee.tar.bz2 vcxsrv-6039fd0faf73c9d6c5b2abf9d824734218ec5eee.zip |
Update to putty 9388
Diffstat (limited to 'tools/plink/wincons.c')
-rw-r--r-- | tools/plink/wincons.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/tools/plink/wincons.c b/tools/plink/wincons.c index 4f984d958..41bbc130d 100644 --- a/tools/plink/wincons.c +++ b/tools/plink/wincons.c @@ -201,7 +201,7 @@ int askalg(void *frontend, const char *algtype, const char *algname, * Ask whether to wipe a session log file before writing to it.
* Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
*/
-int askappend(void *frontend, Filename filename,
+int askappend(void *frontend, Filename *filename,
void (*callback)(void *ctx, int result), void *ctx)
{
HANDLE hin;
@@ -223,11 +223,11 @@ int askappend(void *frontend, Filename filename, char line[32];
if (console_batch_mode) {
- fprintf(stderr, msgtemplate_batch, FILENAME_MAX, filename.path);
+ fprintf(stderr, msgtemplate_batch, FILENAME_MAX, filename->path);
fflush(stderr);
return 0;
}
- fprintf(stderr, msgtemplate, FILENAME_MAX, filename.path);
+ fprintf(stderr, msgtemplate, FILENAME_MAX, filename->path);
fflush(stderr);
hin = GetStdHandle(STD_INPUT_HANDLE);
@@ -315,7 +315,7 @@ int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen) {
int i;
for (i = 0; i < (int)p->n_prompts; i++)
- memset(p->prompts[i]->result, 0, p->prompts[i]->result_len);
+ prompt_set_result(p->prompts[i], "");
}
/*
@@ -365,9 +365,9 @@ int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen) for (curr_prompt = 0; curr_prompt < p->n_prompts; curr_prompt++) {
- DWORD savemode, newmode, i = 0;
+ DWORD savemode, newmode;
+ int len;
prompt_t *pr = p->prompts[curr_prompt];
- BOOL r;
GetConsoleMode(hin, &savemode);
newmode = savemode | ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT;
@@ -379,25 +379,44 @@ int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen) console_data_untrusted(hout, pr->prompt, strlen(pr->prompt));
- r = ReadFile(hin, pr->result, pr->result_len - 1, &i, NULL);
+ len = 0;
+ while (1) {
+ DWORD ret = 0;
+ BOOL r;
+
+ prompt_ensure_result_size(pr, len * 5 / 4 + 512);
+
+ r = ReadFile(hin, pr->result + len, pr->resultsize - len - 1,
+ &ret, NULL);
+
+ if (!r || ret == 0) {
+ len = -1;
+ break;
+ }
+ len += ret;
+ if (pr->result[len - 1] == '\n') {
+ len--;
+ if (pr->result[len - 1] == '\r')
+ len--;
+ break;
+ }
+ }
SetConsoleMode(hin, savemode);
- if ((int) i > pr->result_len)
- i = pr->result_len - 1;
- else
- i = i - 2;
- pr->result[i] = '\0';
-
if (!pr->echo) {
DWORD dummy;
WriteFile(hout, "\r\n", 2, &dummy, NULL);
}
+ if (len < 0) {
+ return 0; /* failure due to read error */
+ }
+
+ pr->result[len] = '\0';
}
return 1; /* success */
-
}
void frontend_keypress(void *handle)
|