summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-01-06 00:13:13 +0100
committerFelix Fietkau <nbd@openwrt.org>2013-01-06 00:13:13 +0100
commit9d49fe82fd7f57b340004f6fc62dd4509e528931 (patch)
tree3d1d38e3973cb87981098b368bf813b1286d1636 /file.c
parent852a5a4f11f0b4de924a49403ab864cc0584a0ad (diff)
de-constify the url parameter for the handler, it becomes invalid after the request anyway
Diffstat (limited to 'file.c')
-rw-r--r--file.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/file.c b/file.c
index 372696c..5de96f8 100644
--- a/file.c
+++ b/file.c
@@ -644,7 +644,7 @@ dispatch_find(const char *url, struct path_info *pi)
return NULL;
}
-static bool __handle_file_request(struct client *cl, const char *url)
+static bool __handle_file_request(struct client *cl, char *url)
{
static const struct blobmsg_policy hdr_policy[__HDR_MAX] = {
[HDR_AUTHORIZATION] = { "authorization", BLOBMSG_TYPE_STRING },
@@ -684,7 +684,8 @@ static bool __handle_file_request(struct client *cl, const char *url)
void uh_handle_request(struct client *cl)
{
struct dispatch_handler *d;
- const char *url = blobmsg_data(blob_data(cl->hdr.head));;
+ char *url = blobmsg_data(blob_data(cl->hdr.head));;
+ char *error_handler;
d = dispatch_find(url, NULL);
if (d) {
@@ -692,8 +693,12 @@ void uh_handle_request(struct client *cl)
return;
}
- if (__handle_file_request(cl, url) ||
- __handle_file_request(cl, conf.error_handler))
+ if (__handle_file_request(cl, url))
+ return;
+
+ error_handler = alloca(strlen(conf.error_handler) + 1);
+ strcpy(error_handler, conf.error_handler);
+ if (__handle_file_request(cl, error_handler))
return;
uh_client_error(cl, 404, "Not Found", "The requested URL %s was not found on this server.", url);