summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorSebastian Benoit <benno@cvs.openbsd.org>2020-07-30 21:06:20 +0000
committerSebastian Benoit <benno@cvs.openbsd.org>2020-07-30 21:06:20 +0000
commit36a43411090a22228b6eb962100a1349513ac07b (patch)
treefc6405342d12b6f884b9c518f37a8aa865bf4404 /usr.sbin
parentabce0f33cbc81e4243f198eb1a5de2dc7668d7ed (diff)
Remove the unused function canonicalize_host(), it was copied from relayd.
Found by Ross L Richardson, Thanks.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/httpd/httpd.c55
-rw-r--r--usr.sbin/httpd/httpd.h3
2 files changed, 2 insertions, 56 deletions
diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c
index ae0fa879ef5..af04f5c1a5b 100644
--- a/usr.sbin/httpd/httpd.c
+++ b/usr.sbin/httpd/httpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.c,v 1.68 2018/09/09 21:06:51 bluhm Exp $ */
+/* $OpenBSD: httpd.c,v 1.69 2020/07/30 21:06:19 benno Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -552,59 +552,6 @@ expand_string(char *label, size_t len, const char *srch, const char *repl)
}
const char *
-canonicalize_host(const char *host, char *name, size_t len)
-{
- struct sockaddr_in sin4;
- struct sockaddr_in6 sin6;
- size_t i, j;
- size_t plen;
- char c;
-
- if (len < 2)
- goto fail;
-
- /*
- * Canonicalize an IPv4/6 address
- */
- if (inet_pton(AF_INET, host, &sin4) == 1)
- return (inet_ntop(AF_INET, &sin4, name, len));
- if (inet_pton(AF_INET6, host, &sin6) == 1)
- return (inet_ntop(AF_INET6, &sin6, name, len));
-
- /*
- * Canonicalize a hostname
- */
-
- /* 1. remove repeated dots and convert upper case to lower case */
- plen = strlen(host);
- memset(name, 0, len);
- for (i = j = 0; i < plen; i++) {
- if (j >= (len - 1))
- goto fail;
- c = tolower((unsigned char)host[i]);
- if ((c == '.') && (j == 0 || name[j - 1] == '.'))
- continue;
- name[j++] = c;
- }
-
- /* 2. remove trailing dots */
- for (i = j; i > 0; i--) {
- if (name[i - 1] != '.')
- break;
- name[i - 1] = '\0';
- j--;
- }
- if (j <= 0)
- goto fail;
-
- return (name);
-
- fail:
- errno = EINVAL;
- return (NULL);
-}
-
-const char *
url_decode(char *url)
{
char *p, *q;
diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h
index 53dca52f620..94eca5977dc 100644
--- a/usr.sbin/httpd/httpd.h
+++ b/usr.sbin/httpd/httpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.h,v 1.147 2020/07/25 21:12:49 benno Exp $ */
+/* $OpenBSD: httpd.h,v 1.148 2020/07/30 21:06:19 benno Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -710,7 +710,6 @@ void event_again(struct event *, int, short,
int expand_string(char *, size_t, const char *, const char *);
const char *url_decode(char *);
char *url_encode(const char *);
-const char *canonicalize_host(const char *, char *, size_t);
const char *canonicalize_path(const char *, char *, size_t);
size_t path_info(char *);
char *escape_html(const char *);