X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=file.c;h=b2e6adef75917df12965335a28ab750c0428fe91;hb=bb64de8897d9de5c964d021d05999bd4ca5cb36a;hp=372696ca8727dbea673c20fde729ff5b216a4f2a;hpb=cf9c6c30f1328f8804f55896b3fcfcd1f5ae0212;p=project%2Fuhttpd.git diff --git a/file.c b/file.c index 372696c..b2e6ade 100644 --- a/file.c +++ b/file.c @@ -176,6 +176,9 @@ uh_path_lookup(struct client *cl, const char *url) exists = !!canonpath(uh_buf, path_phys); uh_buf[i] = ch; + if (!exists) + continue; + snprintf(path_info, sizeof(path_info), "%s", uh_buf + i); break; } @@ -644,7 +647,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 +687,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,9 +696,15 @@ 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; + if (conf.error_handler) { + 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); }