print a message if a protocol is not supported - gopherproxy-c - Gopher HTTP proxy in C (CGI)
HTML git clone git://git.codemadness.org/gopherproxy-c
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 78efc56f91b0956fe6e2dcc7919a4dcd64dfe66a
DIR parent b4fcf2516500e0d3979721cae7d91f430e72fa41
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Mon, 16 May 2022 14:46:40 +0200
print a message if a protocol is not supported
This would not trigger because URIs are prefixed with gopher:// otherwise.
Reported by parazyd by testing gophers:// which is not supported (yet).
Diffstat:
M gopherproxy.c | 3 +++
1 file changed, 3 insertions(+), 0 deletions(-)
---
DIR diff --git a/gopherproxy.c b/gopherproxy.c
@@ -611,6 +611,8 @@ main(void)
r = snprintf(fulluri, sizeof(fulluri), "%s", query);
} else {
showuri = query;
+ if (uri_hasscheme(query))
+ die(400, "Invalid protocol: only gopher is supported\n");
r = snprintf(fulluri, sizeof(fulluri), "gopher://%s", query);
}
if (r < 0 || (size_t)r >= sizeof(fulluri))
@@ -619,6 +621,7 @@ main(void)
if (!uri_hasscheme(fulluri) ||
uri_parse(fulluri, &u) == -1)
die(400, "Invalid or unsupported URI: %s\n", showuri);
+
if (strcmp(u.proto, "gopher://"))
die(400, "Invalid protocol: only gopher is supported\n");
if (u.host[0] == '\0')