~sircmpwn/gmni-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH gmnisrv] serve: make hostname matching case-insensitive

Details
Message ID
<20211115181344.2334816-1-jb55@jb55.com>
DKIM signature
missing
Download raw message
Patch: +14 -1
Reported-by: James Tomasino <james@tomasino.org>
---
 src/serve.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/serve.c b/src/serve.c
index bcbef5c..c7cc505 100644
--- a/src/serve.c
+++ b/src/serve.c
@@ -1,5 +1,6 @@
#include <arpa/inet.h>
#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
@@ -602,6 +603,18 @@ serve_request(struct gmnisrv_client *client)
	client_submit_response(client, GEMINI_STATUS_SUCCESS, meta, body);
}

static int
stricmp(const char *a, const char *b)
{
	int d;

	for (;; a++, b++) {
		d = tolower(*a) - tolower(*b);
		if (d != 0 || !*a)
			return d;
	}
}

bool
request_validate(struct gmnisrv_client *client, char **path)
{
@@ -637,7 +650,7 @@ request_validate(struct gmnisrv_client *client, char **path)
		client_submit_response(client,
			GEMINI_STATUS_BAD_REQUEST, error, NULL);
		goto exit;
	} else if (strcmp(part, client->host->hostname) != 0) {
	} else if (stricmp(part, client->host->hostname) != 0) {
		free(part);
		const char *error = "Protocol error: hostname does not match SNI";
		client_submit_response(client,
-- 
2.32.0
Details
Message ID
<20211115181905.4kctn5qfnyjm7epl@quiver>
In-Reply-To
<20211115181344.2334816-1-jb55@jb55.com> (view parent)
DKIM signature
missing
Download raw message
I don't think I need stricmp here, looks like there's a strcasecmp
function in strings.h? will redo in v2
Reply to thread Export thread (mbox)