From 5981fdcc7bb9ddc21f7d974fdd4336ab0367dbe9 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 3 Oct 2020 20:17:48 +0200 Subject: [PATCH] Lowercase the host name in functions that set it In case of get_destination_from_https_headers() it's important to get stable hashes for certificates. In case of get_destination_from_headers() and parse_http_url() it's mainly cosmetic. --- parsers.c | 12 ++++++++++-- urlmatch.c | 9 +++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/parsers.c b/parsers.c index 3f704deb..eab5e76b 100644 --- a/parsers.c +++ b/parsers.c @@ -4587,7 +4587,11 @@ jb_err get_destination_from_headers(const struct list *headers, struct http_requ return JB_ERR_PARSE; } - p = strdup_or_die(host); + p = string_tolower(host); + if (p == NULL) + { + return JB_ERR_MEMORY; + } chomp(p); q = strdup_or_die(p); @@ -4674,7 +4678,11 @@ jb_err get_destination_from_https_headers(const struct list *headers, struct htt return JB_ERR_PARSE; } - p = strdup_or_die(host); + p = string_tolower(host); + if (p == NULL) + { + return JB_ERR_MEMORY; + } chomp(p); q = strdup_or_die(p); diff --git a/urlmatch.c b/urlmatch.c index 4886e4c4..23a6b543 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -302,7 +302,7 @@ jb_err parse_http_url(const char *url, struct http_request *http, int require_pr url_path ); *url_path = '\0'; - http->hostport = strdup_or_die(url_noproto); + http->hostport = string_tolower(url_noproto); } else { @@ -311,10 +311,15 @@ jb_err parse_http_url(const char *url, struct http_request *http, int require_pr * or CONNECT requests */ http->path = strdup_or_die("/"); - http->hostport = strdup_or_die(url_noproto); + http->hostport = string_tolower(url_noproto); } freez(buf); + + if (http->hostport == NULL) + { + return JB_ERR_PARSE; + } } if (!host_available) -- 2.39.2