diff options
Diffstat (limited to 'browse.c')
-rw-r--r-- | browse.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -31,6 +31,7 @@ #include <dirent.h> #include <kcgi.h> #include <kcgihtml.h> +#include <limits.h> #include <stdbool.h> #include <string.h> @@ -60,7 +61,7 @@ browse(struct kreq * r) DIR *data_dir; char *file_name; size_t url_size; - char url[URL_LENGTH_MAX], current_dir[URL_LENGTH_MAX]; + char url[PATH_MAX], current_dir[PATH_MAX]; struct khtmlreq html; /* check that the requested URL can be safely processed */ @@ -68,11 +69,11 @@ browse(struct kreq * r) http_exit(r, KHTTP_400, "browse: Invalid request path"); /* list requested directory content */ - url_size = url_build(current_dir, URL_LENGTH_MAX, DATA_DIR, r->path, + url_size = url_build(current_dir, PATH_MAX, DATA_DIR, r->path, NULL); if (url_size == 0) http_exit(r, KHTTP_404, "browse: Unable to build data path"); - if (url_size >= URL_LENGTH_MAX) + if (url_size >= PATH_MAX) http_exit(r, KHTTP_414, NULL); data_dir = opendir(current_dir); if (NULL == data_dir) @@ -99,8 +100,8 @@ browse(struct kreq * r) file_name = dir->d_name; if (strcmp(".", file_name) == 0 || strcmp("..", file_name) == 0) continue; - url_size = build_browse_url(r, url, URL_LENGTH_MAX, file_name); - if (url_size == 0 || url_size >= URL_LENGTH_MAX) { + url_size = build_browse_url(r, url, PATH_MAX, file_name); + if (url_size == 0 || url_size >= PATH_MAX) { kutil_warn(r, NULL, "browse: Detected URL overflow: %s", url); continue; } |