mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-15 18:17:32 -05:00
Use strbuf to store results in prompts_t.
UBsan pointed out another memcpy from NULL (again with length 0) in the prompts_t system. When I looked at it, I realised that firstly prompt_ensure_result_size was an early not-so-good implementation of sgrowarray_nm that would benefit from being replaced with a call to the real one, and secondly, the whole system for storing prompt results should really have been replaced with strbufs with the no-move option, because that's doing all the same jobs better. So, now each prompt_t holds a strbuf in place of its previous manually managed string. prompt_ensure_result_size is gone (the console prompt-reading functions use strbuf_append, and everything else just adds to the strbuf in the usual marshal.c way). New functions exist to retrieve a prompt_t's result, either by reference or copied.
This commit is contained in:
@ -338,7 +338,7 @@ static char *askpass_tty(const char *prompt)
|
||||
free_prompts(p);
|
||||
return NULL;
|
||||
} else {
|
||||
char *passphrase = dupstr(p->prompts[0]->result);
|
||||
char *passphrase = prompt_get_result(p->prompts[0]);
|
||||
free_prompts(p);
|
||||
return passphrase;
|
||||
}
|
||||
|
Reference in New Issue
Block a user