summaryrefslogtreecommitdiff
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
parent852a5a4f11f0b4de924a49403ab864cc0584a0ad (diff)
de-constify the url parameter for the handler, it becomes invalid after the request anyway
-rw-r--r--cgi.c4
-rw-r--r--file.c13
-rw-r--r--lua.c4
-rw-r--r--plugin.h4
-rw-r--r--proc.c4
-rw-r--r--uhttpd.h6
6 files changed, 20 insertions, 15 deletions
diff --git a/cgi.c b/cgi.c
index 2b7cffb..6441fda 100644
--- a/cgi.c
+++ b/cgi.c
@@ -36,7 +36,7 @@ void uh_interpreter_add(const char *ext, const char *path)
list_add_tail(&in->list, &interpreters);
}
-static void cgi_main(struct client *cl, struct path_info *pi, const char *url)
+static void cgi_main(struct client *cl, struct path_info *pi, char *url)
{
const struct interpreter *ip = pi->ip;
struct env_var *var;
@@ -63,7 +63,7 @@ static void cgi_main(struct client *cl, struct path_info *pi, const char *url)
" %s: %s\n", ip ? ip->path : pi->phys, strerror(errno));
}
-static void cgi_handle_request(struct client *cl, const char *url, struct path_info *pi)
+static void cgi_handle_request(struct client *cl, char *url, struct path_info *pi)
{
unsigned int mode = S_IFREG | S_IXOTH;
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);
diff --git a/lua.c b/lua.c
index 0b06a33..7cc05d9 100644
--- a/lua.c
+++ b/lua.c
@@ -200,7 +200,7 @@ error:
return NULL;
}
-static void lua_main(struct client *cl, struct path_info *pi, const char *url)
+static void lua_main(struct client *cl, struct path_info *pi, char *url)
{
struct blob_attr *cur;
const char *error;
@@ -261,7 +261,7 @@ static void lua_main(struct client *cl, struct path_info *pi, const char *url)
exit(0);
}
-static void lua_handle_request(struct client *cl, const char *url, struct path_info *pi)
+static void lua_handle_request(struct client *cl, char *url, struct path_info *pi)
{
static struct path_info _pi;
diff --git a/plugin.h b/plugin.h
index dd73c57..7373d65 100644
--- a/plugin.h
+++ b/plugin.h
@@ -23,8 +23,8 @@ struct uhttpd_ops {
void (*dispatch_add)(struct dispatch_handler *d);
bool (*path_match)(const char *prefix, const char *url);
- bool (*create_process)(struct client *cl, struct path_info *pi, const char *url,
- void (*cb)(struct client *cl, struct path_info *pi, const char *url));
+ bool (*create_process)(struct client *cl, struct path_info *pi, char *url,
+ void (*cb)(struct client *cl, struct path_info *pi, char *url));
struct env_var *(*get_process_vars)(struct client *cl, struct path_info *pi);
void (*client_error)(struct client *cl, int code, const char *summary, const char *fmt, ...);
diff --git a/proc.c b/proc.c
index 8680d01..191579f 100644
--- a/proc.c
+++ b/proc.c
@@ -296,8 +296,8 @@ static int proc_data_send(struct client *cl, const char *data, int len)
return retlen;
}
-bool uh_create_process(struct client *cl, struct path_info *pi, const char *url,
- void (*cb)(struct client *cl, struct path_info *pi, const char *url))
+bool uh_create_process(struct client *cl, struct path_info *pi, char *url,
+ void (*cb)(struct client *cl, struct path_info *pi, char *url))
{
struct dispatch *d = &cl->dispatch;
struct dispatch_proc *proc = &d->proc;
diff --git a/uhttpd.h b/uhttpd.h
index b8dfece..9304670 100644
--- a/uhttpd.h
+++ b/uhttpd.h
@@ -148,7 +148,7 @@ struct dispatch_handler {
bool (*check_url)(const char *url);
bool (*check_path)(struct path_info *pi, const char *url);
- void (*handle_request)(struct client *cl, const char *url, struct path_info *pi);
+ void (*handle_request)(struct client *cl, char *url, struct path_info *pi);
};
struct dispatch {
@@ -237,8 +237,8 @@ void uh_relay_close(struct relay *r, int ret);
void uh_relay_free(struct relay *r);
struct env_var *uh_get_process_vars(struct client *cl, struct path_info *pi);
-bool uh_create_process(struct client *cl, struct path_info *pi, const char *url,
- void (*cb)(struct client *cl, struct path_info *pi, const char *url));
+bool uh_create_process(struct client *cl, struct path_info *pi, char *url,
+ void (*cb)(struct client *cl, struct path_info *pi, char *url));
int uh_plugin_init(const char *name);