Introduction
Introduction Statistics Contact Development Disclaimer Help
parseuri: support IPv6 address for host - gopherproxy-c - Gopher HTTP proxy in …
git clone git://git.codemadness.org/gopherproxy-c
Log
Files
Refs
README
LICENSE
---
commit 9612b7ed97d46f386db7334b7ef880038a92df8c
parent d0cd571a262cbbca3c7d12f08799e6835552bf13
Author: Hiltjo Posthuma <[email protected]>
Date: Fri, 17 Aug 2018 18:37:09 +0200
parseuri: support IPv6 address for host
Diffstat:
M gopherproxy.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/gopherproxy.c b/gopherproxy.c
@@ -446,15 +446,26 @@ parseuri(const char *str, struct uri *u)
memset(u, 0, sizeof(struct uri));
s = str;
- e = &s[strcspn(s, ":/")];
- if (e - s + 1 >= sizeof(u->host))
- return 0;
- memcpy(u->host, s, e - s);
- u->host[e - s] = '\0';
- if (*e == ':') {
- s = ++e;
+ /* IPv6 */
+ if (*s == '[') {
+ s++;
+ e = strchr(s, ']');
+ if (!e || e - s + 1 >= sizeof(u->host))
+ return 0;
+ memcpy(u->host, s, e - s);
+ u->host[e - s] = '\0';
+ e++;
+ } else {
+ e = &s[strcspn(s, ":/")];
+ if (e - s + 1 >= sizeof(u->host))
+ return 0;
+ memcpy(u->host, s, e - s);
+ u->host[e - s] = '\0';
+ }
+ if (*e == ':') {
+ s = e + 1;
e = &s[strcspn(s, "/")];
if (e - s + 1 >= sizeof(u->port))
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.