summaryrefslogtreecommitdiff
path: root/file.c
AgeCommit message (Collapse)Author
2020-02-11file: poke ustream after starting deferred programJo-Philipp Wich
When we're starting a deferred request, the related input ustream might have gone into read_blocked mode because incoming client request data exhausted the ustreams internal buffer space. When this happens, edge triggered uloop read events are "lost" and never re-triggered causing the script input to never complete. In order to avoid that deadlock situation, manually poke the input ustream using ustream_poll() after invoking client_poll_post_data() which should have drained (some) of the buffered input ustream contents. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-09-24file: fix CPP syntax errorJo-Philipp Wich
Fixes: 77b774b ("build: avoid redefining _DEFAULT_SOURCE") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-08-23build: avoid redefining _DEFAULT_SOURCEJo-Philipp Wich
Work around further glibc toolchain annoyances. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-08-21build: use _DEFAULT_SOURCEJo-Philipp Wich
Add _DEFAULT_SOURCE FTM in order to avoid warnings with recent glibc. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-08-21uhttpd: recognize PATCH, PUT and DELETE HTTP methodsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-04file: escape strings in HTML outputJo-Philipp Wich
Escape untrusted input like the request URL or filesystem paths in HTML outputs such as the directory listing or 404 error messages. This fixes certain XSS vulnerabilities which can be leveraged to further exploit the system. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-11-04file: fix query string handlingJo-Philipp Wich
Instead of storing a pointer to the beginning of the query string within the request url, store a copy in a static buffer instead. This aligns handling the query string portion of the url with other elements like physical path or path info information. Since the URL is usually kept in the per-client blob buffer which might change its memory location due to reallocations triggered by blobmsg_add_*, it is not safe to point to it early in the request life cycle. This fixes invalid memory access usually manifesting itself as corrupted query string data in CGI scripts. Reported-by: P. Wassi <p.wassi@gmx.at> Suggested-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-07-09file: fix basic auth regressionJo-Philipp Wich
Previous refactoring of the basic auth handling code broke the logic in such a way that basic auth was only performed if a client sent an Authorization header in its request, but it was never prompted for by the server. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-07-02file: remove unused "auth" member from struct path_infoJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-07-02auth: store parsed username and passwordJo-Philipp Wich
Store the parsed username and password information as HTTP headers in the clients header blob buffer for later use by proc.c Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2016-10-06file: re-run json handler script after file fallback redirectFelix Fietkau
This allows the request handler to add extra headers to the response even in the redirect case. Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-06-16file: add support for disabling cache related precondition checks via handlersFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-06-16uhttpd: add support for adding arbitrary headers via handler scriptsFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2015-11-08file: on redirect, only send content-length header when not using chunked ↵Felix Fietkau
transfer Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-08add support for handling redirects via a scriptFelix Fietkau
In a json_script file you can specify rules for rewriting the URL or redirecting the browser either unconditionally, or as a fallback where it would otherwise print a 404 error Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-10-20fix the alias supportJohn Crispin
the path compare return code was not honoured properly Signed-off-by: John Crispin <blogic@openwrt.org>
2015-10-17add a -y parameter for cgi-bin redirectsJohn Crispin
this allows an alias entry inside the root folder point at a cgi-bin script -y foo=bar will redirect /foo to /cgi-bin/bar Signed-off-by: John Crispin <blogic@openwrt.org>
2015-10-08fix chunked transfer encoding in keepalive modeJo-Philipp Wich
The two commits 5162e3b0ee7bd1d0fd6e75e1ca7993a1834b5291 "allow request handlers to disable chunked reponses" and 618493e378e2239f0d30902e47adfa134e649fdc "file: disable chunked encoding for file responses" broke the chunked transfer encoding handling for proc responses in keep-alive connections that followed a file response with http status 204 or 304. The effect of this bug is that cgi responses following a 204 or 304 one where sent neither in chunked encoding nor with a content-length header, causing browsers to stall until the keep alive timeout was reached. Fix the logic flaw by inverting the chunk prevention flag in the client state and by testing the chunked encoding preconditions every time instead of once upon client (re-)initialization. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-09-24uhttpd: fix wrong header file inclusion for PRI* constant definitionsAndrej Krpic
Signed-off-by: Andrej Krpic <ak77@tnode.com>
2015-09-07file: fix processing POST data for deferred requestsFelix Fietkau
Fixes https://dev.openwrt.org/ticket/20458 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-05-30file: disable chunked encoding for file responsesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-25file: explicitely cast st_mtime to uint64_t when generating ETagJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-18Build with largefile supportJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2014-12-22uhttpd: Fix possible memory leaks when generating directory listingAndrej Krpic
scandir() call requires free() of each returned dirent structure and parent list. Code constructing HTML response of directory listing is missing a call to free in some cases. Signed-off-by: Andrej Krpic <ak77@tnode.com>
2014-10-27file: do not emit Content-Length header for 304/412 responsesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2014-09-03file: invoke error handler in 403 case as wellJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2013-01-19add support for deferring script requests, limit maximum number of script ↵Felix Fietkau
calls to 3, maximum number of connections to 100 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-19properly terminate headers of http responses without data, add Content-Length: 0Felix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-19fix file etag buffer lengthFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-13relicense to ISCFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-13fix redirect statusFelix Fietkau
2013-01-13fix path lookupFelix Fietkau
2013-01-13check for conf.error_handler before using itFelix Fietkau
2013-01-13add missing file exists checkFelix Fietkau
2013-01-06de-constify the url parameter for the handler, it becomes invalid after the ↵Felix Fietkau
request anyway
2013-01-04constify mimetype listFelix Fietkau
2013-01-04clean up directory listing code, only iterate over the set once (by sorting ↵Felix Fietkau
directories before files ahead of time)
2013-01-03fix use-after-realloc issue with the request urlFelix Fietkau
2013-01-03fix index file handlingFelix Fietkau
2013-01-02move timegm declaration to utils.hFelix Fietkau
2013-01-02reduce stack usage of uh_file_dirlistFelix Fietkau
2013-01-02fix buffer handling for time formattingFelix Fietkau
2013-01-02rework string handling for directory listing, avoid redundant string scanningFelix Fietkau
2013-01-02remove a static bufferFelix Fietkau
2013-01-02add auth supportFelix Fietkau
2013-01-01add preliminary cgi support, needs fixing for close handlingFelix Fietkau
2013-01-01append / to directory links to avoid unnecessary redirectsFelix Fietkau
2013-01-01code cleanupFelix Fietkau
2013-01-01rename uhttpd-mimetypes.h to mimetypes.hFelix Fietkau
2012-12-31move dispatch cbs and data to one placeFelix Fietkau