1
0
mirror of https://git.sr.ht/~sircmpwn/gmni synced 2024-11-26 10:53:46 +01:00

fix display of message on TOFU_FINGERPRINT_MISMATCH

Previously the message was never displayed to users
leaving them with a simple "Error: certificate is untrusted".

This also fixes the display of line numbers in the message.
This commit is contained in:
René Wagner 2021-02-23 15:43:06 +01:00 committed by Drew DeVault
parent 529b1059af
commit 863c41dba6
2 changed files with 4 additions and 1 deletions

@ -1022,7 +1022,7 @@ tofu_callback(enum tofu_error error, const char *fingerprint,
free(host); free(host);
break; break;
case TOFU_FINGERPRINT_MISMATCH: case TOFU_FINGERPRINT_MISMATCH:
snprintf(prompt, sizeof(prompt), fprintf(browser->tty,
"The certificate offered by this server DOES NOT MATCH the one we have on file.\n" "The certificate offered by this server DOES NOT MATCH the one we have on file.\n"
"/!\\ Someone may be eavesdropping on or manipulating this connection. /!\\\n" "/!\\ Someone may be eavesdropping on or manipulating this connection. /!\\\n"
"The unknown certificate's fingerprint is:\n" "The unknown certificate's fingerprint is:\n"

@ -188,6 +188,7 @@ gemini_tofu_init(struct gemini_tofu *tofu,
return; return;
} }
n = 0; n = 0;
int lineno = 1;
char *line = NULL; char *line = NULL;
while (getline(&line, &n, f) != -1) { while (getline(&line, &n, f) != -1) {
struct known_host *host = calloc(1, sizeof(struct known_host)); struct known_host *host = calloc(1, sizeof(struct known_host));
@ -211,6 +212,8 @@ gemini_tofu_init(struct gemini_tofu *tofu,
assert(tok); assert(tok);
host->expires = strtoul(tok, NULL, 10); host->expires = strtoul(tok, NULL, 10);
host->lineno = lineno++;
host->next = tofu->known_hosts; host->next = tofu->known_hosts;
tofu->known_hosts = host; tofu->known_hosts = host;
} }