[Privoxy-commits] [privoxy] 06/16: client_host(): Properly handle IPv6 addresses
User Git
git at git.privoxy.org
Thu Oct 9 11:51:28 CEST 2025
This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository privoxy.
commit 4a9d9b5cc41613c6f43d39f8c05abb5382ea0a98
Author: Fabian Keil <fk at fabiankeil.de>
AuthorDate: Thu Sep 11 14:13:57 2025 +0200
client_host(): Properly handle IPv6 addresses
Reported by: Joshua Rogers
---
parsers.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/parsers.c b/parsers.c
index 80297813..b08c381d 100644
--- a/parsers.c
+++ b/parsers.c
@@ -3763,7 +3763,36 @@ static jb_err client_host(struct client_state *csp, char **header)
csp->http->hostport = p;
freez(csp->http->host);
csp->http->host = q;
- q = strchr(csp->http->host, ':');
+
+ if (*p == '[')
+ {
+ /* Numeric IPv6 address delimited by brackets */
+ p++;
+
+ q = strchr(p, ']');
+ if (q == NULL)
+ {
+ /* Missing closing bracket */
+ return JB_ERR_PARSE;
+ }
+
+ *q++ = '\0';
+
+ if (*q == '\0')
+ {
+ q = NULL;
+ }
+ else if (*q != ':')
+ {
+ /* Garbage after closing bracket */
+ return JB_ERR_PARSE;
+ }
+ }
+ else
+ {
+ /* Plain non-escaped hostname */
+ q = strchr(csp->http->host, ':');
+ }
if (q != NULL)
{
/* Terminate hostname and evaluate port string */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Privoxy-commits
mailing list