summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2018-02-13 20:21:52 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-02-13 20:21:52 (GMT)
commite8d8cbf292c9fbc041c346859916db9e7367d4bb (patch) (side-by-side diff)
tree86ba3a1495f3105cccbaaaff1b68fe2ab924d692
parenta60c099c902411f27e93d7aac2323b99696d1a92 (diff)
downloadfileserv-e8d8cbf292c9fbc041c346859916db9e7367d4bb.tar.gz
fileserv-e8d8cbf292c9fbc041c346859916db9e7367d4bb.tar.bz2
Bugfixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/dirconfig.c2
-rw-r--r--src/fileserv.c14
2 files changed, 12 insertions, 4 deletions
diff --git a/src/dirconfig.c b/src/dirconfig.c
index 6cf0a37..d40475d 100644
--- a/src/dirconfig.c
+++ b/src/dirconfig.c
@@ -309,7 +309,7 @@ filename_is_valid(char const *name)
}
state = trans[c][state];
}
- return state != s_err;
+ return state == s_end;
}
int
diff --git a/src/fileserv.c b/src/fileserv.c
index 8f18b92..a7e0bc2 100644
--- a/src/fileserv.c
+++ b/src/fileserv.c
@@ -368,7 +368,7 @@ make_location(char const *proto, char const *host, char const *url)
len = strlen(proto) + 3 + strlen(host) + strlen(url) + 1;
if (url[0] != '/')
len++;
- buf = malloc(len);
+ buf = malloc(len + 1);
if (buf) {
strcpy(buf, proto);
strcat(buf, "://");
@@ -399,6 +399,13 @@ get_sort_ord(struct MHD_Connection *conn)
return s ? index_sort_ord_from_arg(s[0]) : ISO_ASC;
}
+static char const *
+basename(char const *s)
+{
+ char *p = strrchr(s, '/');
+ return p ? p + 1 : s;
+}
+
int
get_file_resp(struct MHD_Connection *conn, char const *url, FILE_RESP *resp)
{
@@ -416,13 +423,14 @@ get_file_resp(struct MHD_Connection *conn, char const *url, FILE_RESP *resp)
map = urimap_find(host, url);
if (!map)
return MHD_HTTP_NOT_FOUND;
- resp->file_name = catfile_n(map->dir, map->dir_len, url + map->uri_len);
+ resp->file_name = catfile_n(map->dir, map->dir_len,
+ url + map->uri_len);
if (lstat(resp->file_name, &resp->st))
return errno_to_http_code(errno);
resp->conf = dirconfig(resp->file_name, map->dir_len);
- if (filename_is_hidden(resp->file_name, resp->conf))
+ if (filename_is_hidden(basename(resp->file_name), resp->conf))
return MHD_HTTP_NOT_FOUND;
if (S_ISLNK(resp->st.st_mode)) {

Return to:

Send suggestions and report system problems to the System administrator.