From b846178443cf1a5dc7c5ea2079fd34fd465af497 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 19 Dec 2023 07:06:21 +0000 Subject: [PATCH] Fix mis-merges from the 0.80 branch. As I mentioned in the previous commit, this merge was nontrivial enough that it wasn't a good idea for the release checklist to suggest doing it in a hurry. And indeed, now I look at it again this morning, there are mistakes: a memory leak of ConsoleIO on the abort path from both affected functions, and a missing space in one of the prompt messages. Now both fixed. --- windows/console.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/windows/console.c b/windows/console.c index 53ae8d16..6db3dd14 100644 --- a/windows/console.c +++ b/windows/console.c @@ -389,8 +389,10 @@ SeatPromptResult console_confirm_ssh_host_key( SeatPromptResult result; const char *prompt = console_print_seatdialogtext(conio, text); - if (!prompt) - return SPR_SW_ABORT("Cannot confirm a host key in batch mode"); + if (!prompt) { + result = SPR_SW_ABORT("Cannot confirm a host key in batch mode"); + goto out; + } ResponseType response; @@ -430,7 +432,7 @@ SeatPromptResult console_confirm_ssh_host_key( put_dataz(conio, console_abandoned_msg); result = SPR_USER_ABORT; } - + out: conio_free(conio); return result; } @@ -443,11 +445,13 @@ SeatPromptResult console_confirm_weak_crypto_primitive( SeatPromptResult result; const char *prompt = console_print_seatdialogtext(conio, text); - if (!prompt) - return SPR_SW_ABORT("Cannot confirm a weak crypto primitive " - "in batch mode"); + if (!prompt) { + result = SPR_SW_ABORT("Cannot confirm a weak crypto primitive " + "in batch mode"); + goto out; + } - put_fmt(conio, "%s (y/n)", prompt); + put_fmt(conio, "%s (y/n) ", prompt); ResponseType response = parse_and_free_response( console_read_line(conio, true)); @@ -458,7 +462,7 @@ SeatPromptResult console_confirm_weak_crypto_primitive( put_dataz(conio, console_abandoned_msg); result = SPR_USER_ABORT; } - + out: conio_free(conio); return result; }