summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-12-11 17:06:56 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-12-11 17:06:56 +0000
commita43ef9f4e1de588a8b9d1d58f293c60cc514c11a (patch)
treed2fdbeb11b3940ab062e0324ed6c833e243be454 /usr.sbin
parent0e1906fe4c4c59ab459336ec72ea2b03b4404c6f (diff)
When scanning backwards for the last dot in a filename,
stop at the '/' marking the beginning of the filename. This allows to configure a Content-Type for a filename without a dot. OK reyk@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/httpd/httpd.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c
index e83d63bf2b9..491c2d4d385 100644
--- a/usr.sbin/httpd/httpd.c
+++ b/usr.sbin/httpd/httpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.c,v 1.27 2014/12/04 02:44:42 tedu Exp $ */
+/* $OpenBSD: httpd.c,v 1.28 2014/12/11 17:06:55 schwarze Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -1116,11 +1116,13 @@ media_find(struct mediatypes *types, char *file)
struct media_type *match, media;
char *p;
- if ((p = strrchr(file, '.')) == NULL) {
- p = file;
- } else if (*p++ == '\0') {
+ /* Last component of the file name */
+ p = strchr(file, '\0');
+ while (p > file && p[-1] != '.' && p[-1] != '/')
+ p--;
+ if (*p == '\0')
return (NULL);
- }
+
if (strlcpy(media.media_name, p,
sizeof(media.media_name)) >=
sizeof(media.media_name)) {