diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-01-06 00:13:13 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-01-06 00:13:13 +0100 |
commit | 9d49fe82fd7f57b340004f6fc62dd4509e528931 (patch) | |
tree | 3d1d38e3973cb87981098b368bf813b1286d1636 | |
parent | 852a5a4f11f0b4de924a49403ab864cc0584a0ad (diff) |
de-constify the url parameter for the handler, it becomes invalid after the request anyway
-rw-r--r-- | cgi.c | 4 | ||||
-rw-r--r-- | file.c | 13 | ||||
-rw-r--r-- | lua.c | 4 | ||||
-rw-r--r-- | plugin.h | 4 | ||||
-rw-r--r-- | proc.c | 4 | ||||
-rw-r--r-- | uhttpd.h | 6 |
6 files changed, 20 insertions, 15 deletions
@@ -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; @@ -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); @@ -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; @@ -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, ...); @@ -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; @@ -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); |