Lowercase the host name in functions that set it
authorFabian Keil <fk@fabiankeil.de>
Sat, 3 Oct 2020 18:17:48 +0000 (20:17 +0200)
committerFabian Keil <fk@fabiankeil.de>
Fri, 9 Oct 2020 07:40:39 +0000 (09:40 +0200)
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
urlmatch.c

index 3f704de..eab5e76 100644 (file)
--- 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);
 
index 4886e4c..23a6b54 100644 (file)
@@ -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)