summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd/server_http.c
AgeCommit message (Collapse)Author
2017-03-10Sync from relayd: DELETE can have a body.Reyk Floeter
Fix by Rivo Nurges, fixes a problem with Atlassian JIRA OK benno@
2017-02-07Improve parsing of the HTTP request lineReyk Floeter
Make sure that the beginning of a new request starts with an alphabetic character. This is a quick way to detect non-ASCII requests (eg. TLS on port 80). The full validation of the request method is done once the input line is read. Make sure that non-terminated lines do not exceed the SERVER_MAXHEADERLENGTH which is 8k. As the current read watermark is set to 64k, this means that the limit check is triggered after max. 64k of input, depending on the TCP read buffer. OK benno@ jsing@
2017-02-02Fix support for HTTP pipelining by handling all requests in the buffer.Reyk Floeter
Tested & OK jung@
2017-01-31Reimplement httpd's support for byte ranges.Reyk Floeter
The previous implementation loaded all the output into a single output buffer and used its size to determine the Content-Length of the body. The new implementation calculates the body length first and writes the individual ranges in an async way using the bufferevent mechanism. This prevents httpd from using too much memory and applies the watermark and throttling mechanisms to range requests. Problem reported by Pierre Kim (pierre.kim.sec at gmail.com) OK benno@ sunil@
2017-01-31The variable clt_done is used in too many places.Reyk Floeter
Introduce a new variable clt_headersdone in the async HTTP parser. OK sunil@ benno@
2016-08-26Replace the static env variables with a single global variable.Rafael Zalamena
ok reyk@
2016-07-27According to RFC 7231 4.3.7, OPTIONS may have body. "Although thisReyk Floeter
specification does not define any use for such a payload, future extensions to HTTP might use the OPTIONS body to make more detailed queries about the target resource." The future has arrived. Found and tested by Michael Lechtermann OK benno@
2016-05-27Return "400 Bad Request" instead of "500 Server Internal Error" forKenneth R Westerback
requests lacking "HTTP/<version>". This makes it more obvious that httpd(8) does not attempt to support HTTP v0.9 (circa 1991), when "GET <url>\r\n" was valid. ok millert@ florian@
2016-05-22makes sure the value of the asprintf buffer is zeroed on errorJoerg Jung
from Hiltjo Posthuma "do." deraadt
2016-03-08Set content charset for auto index generated page.Florian Obser
Pointed out and diff by dhill, thanks! Tweaks and same change for error documents by me.
2016-02-11Back out previous; requested by jung@Tim van der Molen
2016-02-11Include the server port number in the common and combined logs. This is usefulTim van der Molen
to distinguish between http and https requests. OK florian@ reyk@ a while ago
2015-12-07No need to check for NULL before free().mmcc
2015-12-03Remove unnecessary NULL checks before free().Reyk Floeter
From Jan Schreiber
2015-10-13Plug a leak.Sunil Nimmagadda
Ok gilles@, reyk@
2015-10-13Pass unsigned chars to ctype functions.Reyk Floeter
From Michael McConville
2015-09-07Fix a regression that was introduced with server.c r1.64: Do NOT freeReyk Floeter
srv_conf->auth in serverconfig_free() because it was not allocated in config_getserver() but assigned as a reference by id from a global list that is maintained independently. This fixes a potential double-free. This fix also makes srv_conf->auth "const" to emphasize that the read-only auth pointer was not allocated here. OK jsing@
2015-08-21The WebDAV MOVE method was not included in the switch statementReyk Floeter
handling the HTTP methods in server_http.c which resulted in a 405 method not allowed error when trying to use it. Fix by jaminh on github
2015-08-20Change httpd(8) to use C99-style fixed-width integers (uintN_t insteadReyk Floeter
of u_intN_t) and replace u_int with unsigned int. Mixing both variants is a bad style and most contributors seem to prefer this style; it also helps us to get used to it, portability, and standardization. Theoretically no binary change, except one in practice: httpd.o has a different checksum because gcc with -O2 pads/optimizes "struct privsep" differently when using "unsigned int" instead "u_int" for the affected members. "u_int" is just a typedef of "unsigned int", -O0 doesn't build the difference and clang with -O2 doesn't do it either - it is just another curiosity from gcc-land. OK semarie@
2015-07-31repair hsts header output, wrong format strings caused brokenSebastian Benoit
Strict-Transport-Security headers. Add __format__ attribute to kv_set() and kv_setkey() to make it easier to spot such problems. Found by and fix from Donovan Watteau <tsoomi -AT- gmail -DOT- com>, thanks for your help. ok deraadt@
2015-07-29backout the previous: it broke wordpress somehow.Reyk Floeter
we need more care to find a proper fix for the fastcgi headers. acknowledged by deraadt@
2015-07-29Read fcgi response records until we have the whole http header and canFlorian Obser
parse it. Otherwise http headers can leak into the body. Pointed out by Jean-Philippe Ouellet on bugs@ Thanks! OK reyk, commit ASAP deraadt@
2015-07-23The realm in authenticate directive of config file isn't escaped for '"' char.Sebastien Marie
The diff corrects this problem by using VIS_DQ. ok reyk@ florian@
2015-07-19For the completeness of HSTS, add the non-standard preload option.Reyk Floeter
OK florian@
2015-07-18Allow to change the default media type globally or per-location,Reyk Floeter
eg. default type text/html. OK florian@
2015-07-18Implement HTTP Strict Transport Security (HSTS).Florian Obser
Input & OK reyk
2015-07-16spacingReyk Floeter
2015-07-15Escape the message in server_log() as well.Reyk Floeter
OK benno@
2015-07-15For some values like the User-Agent, use vis(3) instead of url_encode().Reyk Floeter
This makes the output more readable and matches Apache's log encoding. OK sthen@ brynet@
2015-07-15Simplify the error path of the previous commit: by using ret = -1 byReyk Floeter
default and only setting it to 0 on success, we don't have to set it in each error case. While here, also remove two superfluous NULL checks (as pointed out by semarie). OK semarie@
2015-07-15httpd don't sanitize variables before putting them in logs. It is possible forsemarie
an attacker to push arbitaries characters in logs (newline for forging entries, or some control escaping interpreted by terminal emulator). OK reyk@
2015-06-23escape the matched substrings before using it in expansion.semarie
ok reyk@
2015-06-23Add initial support for pattern matching using Lua's pattern matching code.Reyk Floeter
With important help on the pattern matcher from semarie@ OK semarie@
2015-06-22After the last change, we also have to url_encode $SERVER_NAME andReyk Floeter
$REMOTE_USER before using them in the Location. From Sebastien Marie (semarie)
2015-06-21When encoding the Location url, only encode the query and pathReyk Floeter
elements from the user input and not the constants from the configuration. This makes it possible to specify chars like '?' in the uri. OK Sebastien Marie
2015-05-20Use off_t instead of size_t to pass file size and print it using %lld whenMark Kettenis
constructing the Content-Length header field. Should fix some, but probably not all, problems with serving files bigger than 2G on 32-bit architectures. ok reyk@, florian@
2015-05-03Implement byte ranges.Florian Obser
From Sunil Nimmagadda <sunil At nimmagadda DOT net> OK benno@
2015-04-18Regis Leroy reported that httpd does not strictly accept CRLF forJonathan Gray
newlines which could lead to http response splitting/smuggling if a badly behaved proxy is in front of httpd. Switch from evbuffer_readline() to evbuffer_readln() with EVBUFFER_EOL_CRLF_STRICT to avoid this. ok florian@
2015-04-09Revert previous as this breaks stuff.Florian Obser
I fscked up the testing, sorry! Found the hard way by jsg@
2015-04-08Do not silently accept multiple Content-Length headers.Florian Obser
Pointed out by Regis Leroy (regis.leroy AT makina-corpus DOT com), thanks! Tweak and OK reyk@
2015-02-23Allow to specify CGI variables as macros in redirection strings, eg.Reyk Floeter
block return 301 "http://www.example.com/$REQUEST_URI" OK tedu@ florian@
2015-02-08spacingReyk Floeter
2015-02-07spacingReyk Floeter
2015-02-07Add support for blocking, dropping, and redirecting requests.Reyk Floeter
OK florian@
2015-02-06Fix log options in locations.Reyk Floeter
Reported and tested by Markus Bergkvist OK florian@
2015-02-05Fix potential NULL pointer dereference.Reyk Floeter
2015-01-21httpd is based on relayd and had included many headers that are onlyReyk Floeter
needed by its ancestor. jsg@, include-what-you-use, and some manual review helped to cleanup the headers (take iwyu with a grain of salt). Based on common practice, httpd.h now also includes the necessary headers for itself. OK florian@
2015-01-19Log the remote user in the access.log.Florian Obser
Pointed out by, tweak & OK reyk@
2015-01-19s/clt_fcgi_remote_user/clt_remote_user/Florian Obser
OK reyk@
2015-01-19Decouple auth parameters from struct server_config into struct auth.Reyk Floeter
OK florian@