cgmnlm

colorful gemini line mode browser
git clone https://git.clttr.info/cgmnlm.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 4b8ae39d89efef677161dbec5fa85e3cfaf61305
parent 46f1644deb98596385ff378bd12069e799a8fb2d
Author: Ondřej Fiala <fiala.ondrej@volny.cz>
Date:   Thu,  9 Nov 2023 03:03:50 +0100

gmnlm: include hostname in TOFU error messages

Diffstat:
Msrc/gmnlm.c | 22+++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/gmnlm.c b/src/gmnlm.c @@ -1351,26 +1351,26 @@ tofu_callback(enum tofu_error error, const char *fingerprint, return browser->tofu_mode; } + char *host; + if (curl_url_get(browser->url, CURLUPART_HOST, &host, 0) != CURLUE_OK) { + fprintf(stderr, "Error: invalid URL %s\n", + browser->plain_url); + return TOFU_FAIL; + } static char prompt[8192]; switch (error) { case TOFU_VALID: assert(0); // Invariant case TOFU_INVALID_CERT: snprintf(prompt, sizeof(prompt), - "The certificate offered by this server IS INVALID.\n" + "The certificate offered by %s IS INVALID.\n" "/!\\ Someone may be eavesdropping on or manipulating this connection. /!\\\n" "If you choose to proceed, you should not disclose personal information or trust " "the contents of the page.\n" "[A]bort; trust [o]nce\n" - "=> "); + "=> ", host); break; case TOFU_UNTRUSTED_CERT:; - char *host; - if (curl_url_get(browser->url, CURLUPART_HOST, &host, 0) != CURLUE_OK) { - fprintf(stderr, "Error: invalid URL %s\n", - browser->plain_url); - return TOFU_FAIL; - } snprintf(prompt, sizeof(prompt), "The certificate offered by %s is of unknown trust. " "Its fingerprint is: \n" @@ -1381,9 +1381,9 @@ tofu_callback(enum tofu_error error, const char *fingerprint, "=> ", host, fingerprint); free(host); break; - case TOFU_FINGERPRINT_MISMATCH: + case TOFU_FINGERPRINT_MISMATCH:; snprintf(prompt, sizeof(prompt), - "The certificate offered by this server DOES NOT MATCH the one we have on file.\n" + "The certificate offered by %s DOES NOT MATCH the one we have on file.\n" "/!\\ Someone may be eavesdropping on or manipulating this connection. /!\\\n" "The unknown certificate's fingerprint is:\n" "%s\n\n" @@ -1392,7 +1392,7 @@ tofu_callback(enum tofu_error error, const char *fingerprint, "If you choose to proceed, you should not disclose personal information or trust " "the contents of the page.\n" "[A]bort; trust [o]nce; [t]rust anyway\n" - "=> ", fingerprint, khost->fingerprint); + "=> ", host, fingerprint, khost->fingerprint); break; }