~sircmpwn/gmni-devel

gmni: show proper message on TOFU_FINGERPRINT_MISMATCH v1 PROPOSED

René Wagner: 1
 show proper message on TOFU_FINGERPRINT_MISMATCH

 2 files changed, 4 insertions(+), 1 deletions(-)
Of course, the commit message was somewhat short.

----
@@ -1106,7 +1106,7 @@ tofu_callback(enum tofu_error error, const char*fingerprint,
 		free(host);
 		break;
 	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
----
Actually show the message to the user with fprintf.
The "prompt" variable put togehter with snprintf is only used when reaching
line 1040 which in this case isn't reached due the return in line 1035.
The user ends up with a simple "Error: certificate is untrusted"

The adjustment in tofu.c ensures that the correct line number (line 1032 in gmnlm.c) is shown
if the TOFU_FINGERPRINT_MISMATCH is hit.
It only showed :0 before.
Can you send a new patch with a better commit message?
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/gmni-devel/patches/20465/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH gmni] show proper message on TOFU_FINGERPRINT_MISMATCH Export this patch

---
 src/gmnlm.c | 2 +-
 src/tofu.c  | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gmnlm.c b/src/gmnlm.c
index 930ab19..1292bb6 100644
--- a/src/gmnlm.c
+++ b/src/gmnlm.c
@@ -1106,7 +1106,7 @@ tofu_callback(enum tofu_error error, const char *fingerprint,
		free(host);
		break;
	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"
			"/!\\ Someone may be eavesdropping on or manipulating this connection. /!\\\n"
			"The unknown certificate's fingerprint is:\n"
diff --git a/src/tofu.c b/src/tofu.c
index ba54933..48395c0 100644
--- a/src/tofu.c
+++ b/src/tofu.c
@@ -188,6 +188,7 @@ gemini_tofu_init(struct gemini_tofu *tofu,
		return;
	}
	n = 0;
	int lineno = 1;
	char *line = NULL;
	while (getline(&line, &n, f) != -1) {
		struct known_host *host = calloc(1, sizeof(struct known_host));
@@ -211,6 +212,8 @@ gemini_tofu_init(struct gemini_tofu *tofu,
		assert(tok);
		host->expires = strtoul(tok, NULL, 10);

		host->lineno = lineno++;

		host->next = tofu->known_hosts;
		tofu->known_hosts = host;
	}
-- 
2.30.1
This commit doesn't really make sense. Can you add some context?