Commit Graph

92 Commits

Author SHA1 Message Date
martin 751561f1f5 Pull up the following via patch, requested by mrg in ticket #1668:
Makefile			1.30-1.31
	Makefile.boot			1.7-1.9
	auth-bozo.c			1.25-1.26
	bozohttpd.8			1.80-1.87
	bozohttpd.c			1.114-1.123,1.125-1.128
	bozohttpd.h			1.61-1.68
	cgi-bozo.c			1.49-1.53
	content-bozo.c			1.17-1.20
	daemon-bozo.c			1-.22
	dir-index-bozo.c		1.33-1.34
	main.c				1.23-1.27
	printenv.lua			1.4-1.5
	ssl-bozo.c			1.27-1.29
	libbozohttpd/libbozohttpd.3	1.5-1.6
	small/Makefile			1.4
	testsuite/Makefile		1.14
	testsuite/t16.in		1.1
	testsuite/t16.out		1.1
	testsuite/t17.in		1.1
	testsuite/t17.out		1.1
	testsuite/t18.in		1.1
	testsuite/t18.out		1.1

Update to bozohttpd 20210227.


changes in bozohttpd 20210227:
	o  new support for content types: .tar.bz2, .tar.xz, .tar.lz,
	   .tar.zst, .tbz2, .txz, .tlz, .zipx, .xz, .zst, .sz, .lz, .lzma,
	   .lzo, .7z, .lzo, .cab, .dmg, .jar, and .rar.  should fix
	   netbsd PR#56026:
	   MIME type of .tar.xz file on ny{cdn,ftp}.NetBSD.org is invalid

changes in bozohttpd 20210211:
	o  fix various NULL derefs from malformed headers.  mostly from
	   <emily@ingalls.rocks>.
	o  fix memory leaks in library interface: add bozo_cleanup().

changes in bozohttpd 20201014:
	o  also set -D_GNU_SOURCE in Makefile.boot.  from
	   hadrien.lacour@posteo.net.
	o  fix array size botch (assertion, not exploitable.)  from
	   martin@netbsd.org.
	o  also match %2F as well as %2f.  from leah@vuxu.org.
	o  many manual and help fixes.  clean ups for higher lint levels,
	   consistency/style clean ups.  various option fixes including made
	   -f imply -b.  from <henrik@gulbra.net> for freebsd.

changes in bozohttpd 20200912:
	o  add .m4a and .m4v file extensions.

changes in bozohttpd 20200820:
	o  make this work on sun2 by reducing mmap window there.
	o  fix SSL shutdown sequence.  from spz@netbsd.org.
	o  add readme support to directory indexing.  from jmcneill@netbsd.org
	o  add blocklist(8) support.  from jruoho@netbsd.org.
2021-03-27 13:38:51 +00:00
martin 43394fc1c2 Pull up following revision(s) (requested by hannken in ticket #1624):
libexec/httpd/bozohttpd.c: revision 1.124

Bozohttpd clobbers files greater than 4GB on 32bit archs.
Make sure the alignment mask derived from pagesize is an off_t.
2020-11-19 11:27:22 +00:00
martin 572271ed8f Pull up the following revisions (via patch) requested by mrg in ticket #1281:
libexec/httpd/CHANGES			1.31-1.40
	libexec/httpd/Makefile			1.28
	libexec/httpd/auth-bozo.c		1.23-1.24
	libexec/httpd/bozohttpd.8		1.75-1.79
	libexec/httpd/bozohttpd.c		1.100-1.113
	libexec/httpd/bozohttpd.h		1.58-1.60
	libexec/httpd/cgi-bozo.c		1.46-1.48
	libexec/httpd/daemon-bozo.c		1.20-1.21
	libexec/httpd/dir-index-bozo.c		1.29-1.32
	libexec/httpd/ssl-bozo.c		1.26
	libexec/httpd/testsuite/Makefile	1.12-1.13
	libexec/httpd/testsuite/t11.out		1.2
	libexec/httpd/testsuite/test-bigfile	1.6
	libexec/httpd/testsuite/test-simple	1.6


Don't display special files in the directory index.  They aren't
served, but links to them are generated.
---
All from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>:
- use html tables for directory index.
- don't include "index.html" in html headers
- additional escaping of names
- re-add top/bottom borders
- adds an aquamarine table header
- Zebra-stripes table rows using CSS instead of code
- fix CGI '+' param and error handling.
- remove unused parameter to daemon_poll_err().
- avoid sign extension in % handling
fix a few problems pointed out by clang static analyzer:
- bozostrnsep() may return with "in = NULL", so check for it.
- nul terminating in bozo_escape_rfc3986() can be simpler
- don't use uniinit variables in check_remap()
- don't use re-used freed data in check_virtual().
- fix bozoprefs->size setting when increasing the size (new total was
  being added to the prior total.)
  however, bozostrdup() may reference request->hr_file.
---
Add ssl specific timeout value (30s).  If SSL_accept() doesn't
work with in this timeout value, ssl setup now fails.
---
Fix handling of bozo_set_timeout() timeouts (and `-T' option parsing)
---
Avoid .htpasswd exposure to authenticated users when .htpasswd is
in the slashdir too.
---
Avoid possible NULL dereference when sending a big request that timeout.
---
Use strings.h for strcasecmp (on linux)
---
Account for cgihandler being set when counting the number of CGI environment
headers we are about to set. Avoids an assertion failure (and overruninng
the array) later.
2019-06-12 10:32:00 +00:00
martin ae291bc01b Pull up following revision(s) (requested by mrg in ticket #1109):
libexec/httpd/main.c: revision 1.22
	libexec/httpd/CHANGES: revision 1.29
	libexec/httpd/cgi-bozo.c: revision 1.45
	libexec/httpd/bozohttpd.h: revision 1.57
	libexec/httpd/CHANGES: revision 1.30
	libexec/httpd/bozohttpd.c: revision 1.97
	libexec/httpd/bozohttpd.c: revision 1.98
	libexec/httpd/bozohttpd.c: revision 1.99

one semicolon is usually enough.

 -

appease lint

- add FALLTHROUGH comment
- one return is usually enough.

 -

avoid c99ism.

 -

fix -X option parsing.  noted by Rajeev V. Pillai.

 -

add option fixes here.

 -

normalise some messages.
2018-11-28 19:50:37 +00:00
martin 7c3b94ce17 Sync to HEAD (requested by mrg in ticket #1104)
libexec/httpd/testsuite/data/.bzremap           up to 1.1
	libexec/httpd/testsuite/t12.out                 up to 1.1
	libexec/httpd/testsuite/t12.in                  up to 1.1
	libexec/httpd/testsuite/t13.out                 up to 1.1
	libexec/httpd/testsuite/t13.in                  up to 1.1
	libexec/httpd/testsuite/t14.out                 up to 1.1
	libexec/httpd/testsuite/t14.in                  up to 1.1
	libexec/httpd/testsuite/t15.out                 up to 1.1
	libexec/httpd/testsuite/t15.in                  up to 1.1
	libexec/httpd/CHANGES                           up to 1.28
	libexec/httpd/auth-bozo.c                       up to 1.22
	libexec/httpd/bozohttpd.8                       up to 1.74
	libexec/httpd/bozohttpd.c                       up to 1.96
	libexec/httpd/bozohttpd.h                       up to 1.56
	libexec/httpd/cgi-bozo.c                        up to 1.44
	libexec/httpd/content-bozo.c                    up to 1.16
	libexec/httpd/daemon-bozo.c                     up to 1.19
	libexec/httpd/dir-index-bozo.c                  up to 1.28
	libexec/httpd/main.c                            up to 1.21
	libexec/httpd/ssl-bozo.c                        up to 1.25
	libexec/httpd/tilde-luzah-bozo.c                up to 1.16
	libexec/httpd/lua/bozo.lua                      up to 1.3
	libexec/httpd/lua/glue.c                        up to 1.5
	libexec/httpd/lua/optparse.lua                  up to 1.2
	libexec/httpd/testsuite/Makefile                up to 1.11
	libexec/httpd/testsuite/html_cmp                up to 1.6
	libexec/httpd/testsuite/t3.out                  up to 1.4
	libexec/httpd/testsuite/t5.out                  up to 1.4
	libexec/httpd/testsuite/t6.out                  up to 1.4
	libexec/httpd/testsuite/test-bigfile            up to 1.5
	libexec/httpd/testsuite/test-simple             up to 1.5


Cosmetic changes to Lua binding in bozohttpd.

- Don't use negative indicies to read arguments of Lua functions.
- On error, return nil, "error string".
- Use ssize_t for return values from bozo_read() and bozo_write().
- Prefer lstring especially when if saves you from appending NUL and
  doing len + 1 which can potentially wraparound.
- Don't mix C allocations with Lua functions marked with "m" in the Lua
  manual. Those functions may throw (longjump) and leak data allocated
  by C function. In one case, I use luaL_Buffer, in the other case,
  I rearranged calls a bit.


fix ordering of a couple of words.  from Edgar Pettijohn in PR#52375.
thanks!


s/u_int/unsigned/.

from Jan Danielsson.  increases/fixes portability.


PR bin/52194: bozohttpd fails to exec scripts via the -C mechanism
sometimes with EFAULT due to not NULL terminated environment.


Document script handler issues with httpd(8).
From martin@, addressing PR 52194.

While here, use American spelling consistently and upper-case some
abbreviations.

Bump date.


fix output since protocol agnostic change went in.

XXX: i thought someone hooked this into atf already, please do :)


Add support for remapping requested paths via a .bzredirect file.
Fixes PR 52772. Ok: mrg@


Bump date


Remove trailing whitespace.


use __func__ in debug().


fix a denial of service attack against header contents, which
is now bounded at 16KiB.  reported by JP.


avoid memory leak in sending multiple auth headers.
mostly mitigated by previous patch to limit total header size,
but still a real problem here.


note the changes present in bozohttpd 20181118:

o  add url remap support via .bzremap file, from martin%netbsd.org@localhost
o  handle redirections for any protocol, not just http:
o  fix a denial of service attack against header contents, which
   is now bounded at 16KiB.  reported by JP.


from CHANGES:

o  reduce default timeouts, and add expand timeouts to handle the
   initial line, each header, and the total time spent
o  add -T option to expose new timeout settings
o  minor RFC fixes related to timeout handling responses

old timeouts:
60 seconds for initial request like, 60 seconds per header line,
and no whole timeout (though the recent total header size changes
do introduce one that would be about 11 hours.)
new timeouts:
30 seconds for initial request like, 10 seconds per header line,
and a total request time of 600 seconds.

the new global timeout is implemented using CLOCK_MONOTONIC, with
a fallback to CLOCK_REALTIME if monotonic time is unavailable.

reject multiple Host: headers.  besides being protocol standard,
this closes one additional memory leak found by JP.  add a simple
test to check this.

clean up option and usage handling some.


move some #if support into bozohttpd.h.


fix previous: have_debug was reversed.


also fix have_dynamic_content from the previous previous.  re-order
the debug and dynamic content to match the same pattern as everything
else so similar problems are less likely in the future.


- move special files defines into bozohttpd.h, so we can ...
- consolidate all the special file checks into
  bozo_check_special_files() so that all builds check the same
  list of special files, regardless of build options.
- convert "(void)bozo_http_error(...); return -1;" into plain
  "return bozo_http_error(...);"
- fix the call to bozo_check_special_files() to be used on all
  input types.  part of the fixes for failure to reject access
  to /.htpasswd as reported by JP on tech-security.
- use warn_unused_result attribute on bozo_check_special_files(),
  and fix the failures to return failure.  second part of the
  htpasswd access fix.
- update testsuite to use a fixed fake hostname.

call this bozohttpd 20181121.


two fixes reported by mouse:
- don't check contents of 'st' if stat(2) failed.
- round up instead of truncate.  now 10000 byte files say 10kB not 9kB.


use MAP_SHARED for the bzremap file.  avoids netbsd kernel complaining:

WARNING: defaulted mmap() share type to MAP_PRIVATE (pid 15478 command bozohttpd)


many clean ups:
- keep a list of special files and their human names
- remove (void) casts on bozo_http_error()
- fix a few more misuses of bozo_http_error()
- rename check_mapping() to check_remap() and perform some CSE
- switch away from ``%s'' to '%s'
- remove a bunch of #ifdef using new have_feature defines


alpha sort the option switch.


add an assert() check on array bounds.


minor style fixes.  simplify bozo_match_content_map().
2018-11-24 17:13:51 +00:00
martin e7b19ee5dc Pull up following revision(s) (requested by maya in ticket #522):
libexec/httpd/bozohttpd.c: revision 1.87
Use a protocol-agnostic URL (don't degrade HTTPS->HTTP)
Suggested by Travis Paul in PR bin/52958.
2018-02-04 12:49:25 +00:00
mrg 002f468d50 uh, this is actually called 20170201 :-) 2017-02-05 01:55:03 +00:00
mrg 630f2c0b49 call this bozohttpd 20170201. 2017-01-31 14:36:09 +00:00
mrg 48524f008b there was a bug fix in july. call this 20160720. 2016-12-11 20:40:41 +00:00
mrg da548da125 update the -V documentation to be more clear about what it does.
inspired by Swift Griggs on netbsd-users.
2016-10-04 18:33:00 +00:00
mrg 9d18868a64 avoid an impossible case the compiler can't quite tell. 2016-06-30 13:17:48 +00:00
agc 205633288c As proposed in:
http://mail-index.netbsd.org/tech-userlevel/2016/05/18/msg009999.html

and

	https://www.netbsd.org/~agc/bozo-20160517.diff

add a patch to httpd to return the version string of httpd itself, and use the
-G option on the command line to enable this. This gives httpd the ability to
show, from the command line, what version is running.

	% /usr/build/obj/x86_64/usr/src/libexec/httpd/bozohttpd -G
	bozohttpd version bozohttpd/20160415
	%
2016-05-24 21:18:29 +00:00
mrg 27da98ff14 updates and bozohttpd 20160415:
o  add search-word support for CGI
o  fix a security issue in CGI suffix handler support which would
   allow remote code execution, from shm@netbsd.org
o  -C option supports now CGI scripts only
2016-04-15 17:57:21 +00:00
elric 591b978b80 Fix bug in cleanup of reply headers. 2016-01-02 20:35:59 +00:00
elric afe55bf842 Add the concept of ``reply headers'', that is a SIMPLEQ of headers that
will be included in the HTTP reply.  We define this as we are about to
add an authentication method that may need to have a conversation with
the client.
2016-01-02 18:40:13 +00:00
mrg 0841a79ea3 bump the version; we have real fixes now. 2015-12-31 04:58:43 +00:00
mrg 84411b5891 rewrite the redirection url generation code to use bozoasprintf(). 2015-12-29 04:30:33 +00:00
mrg c2e98309d5 - convert most asprintf() calls to bozoasprintf().
- don't call getpwuid(0) if we don't need to, or fail it it fails,
  and remove the 'username' member of bozohttpd_t since it is not
  used outside of bozo_setup().
2015-12-29 04:21:46 +00:00
mrg 881b8188de rename bozo_err/bozo_warn/bozo_asprintf to bozoerr/etc.
new rule is that function that mirror libc-style functions get no underscore.
2015-12-28 07:37:59 +00:00
mrg cff2d95613 several clean ups:
- bozostrdup() gains a request parameter, and uses it to determine
  what sort of error handling is required
- bozo_strdup() dies
- size_arrays() reduced slightly, pushing error handling into the caller
- convert to size_t for some array indices
- bozo_set_pref() and bozo_init_prefs() gain httpd parameters
- apply a bunch of manual CSE to vastly reduce the number of times the
  string "request->hr_httpd" appears.
- CGI parse_header() takes a request not httpd now

XXX: lua glue updated to call bozo_init_prefs() with htttpd parameter,
     but i'm only guessing here.
2015-12-27 10:21:35 +00:00
christos f47ab3a37e Introduce bozo_strdup and bozo_asprintf to add error checking and reduce
code duplication.

Note that bozo_strdup is different that bozostrdup; the _ routines exit
loging error to syslog or stderr, whereas the non _ routines send error
responses to the http client.
2015-12-12 18:06:58 +00:00
christos 59f3853f3e handle asprintf errors consistently. 2015-10-31 00:55:17 +00:00
christos e3e5f7f09b fix wrong variable 2015-10-30 23:45:31 +00:00
christos 1932f6942a simplify 2015-10-30 23:27:47 +00:00
christos b44c2ed92e - don't use alloca and then check if alloca returns null and then try to
free it. Allocating from the stack does not return null, and freeing it
  will have unpredictable results. use malloc instead.
- now we are using malloc remove -Wno-stack-protector kludge
2015-10-30 23:21:05 +00:00
shm c4fe1fac22 * add CGI support for ~user translation (-E switch)
* add redirects to ~user translation
* fix bugs around ~user translation
* add schema detection for absolute redirects
* fixed few memory leaks
* bunch of minor tweaks
* removed -r support
* smarter redirects

OK mrg@
2015-10-28 09:20:15 +00:00
shm 51b65afab5 Fix handling path with multiple slashes at the beginning
Fix redirections escaping for user support

OK mrg@
2015-07-16 12:19:23 +00:00
shm 5f066e934a Remove d_namelen as it's an BSD extension. Fix building bozohttpd on SunOS.
OK mrg@
2015-07-09 12:32:16 +00:00
mrg 56ba1ad0cf fix content type handling to not hard code (wrong) values for length,
but just call strlen() as needed.  call this 20150501.

reported by Jan Danielsson for ".svg".
2015-05-02 11:35:48 +00:00
mrg 4135f5d46d copyright maintenance, note shm@ in the manual and update the CHANGES
for recent changes.  call this 20150320.
2015-03-20 19:54:53 +00:00
mrg bcc73e9553 don't quote /. it doesn't work. this should fix PR#49765. 2015-03-20 18:54:18 +00:00
snj 411a393d8d spit out a 403 not just when an open() fails with EPERM, but with
EACCES as well.
2015-01-27 04:20:23 +00:00
mrg 2b5d1d7deb call this 20141225. 2014-12-25 18:53:06 +00:00
shm 60a0878843 Fixed memory leak in case of multiple authentication headers sent by the
client.

OK mrg@
2014-11-21 08:58:28 +00:00
shm b8c713d1a2 Fixed off-by-one in virtualhost processing. Previous code was checking if
Host header is a prefix of any existing vhost. This behaviour might be used to
uncover existing vitual hosts from the remote.

OK @mrg
2014-11-21 08:54:12 +00:00
mrg 6ec24a2914 don't truncate file sizes to 32 bits for directory indexes. 2014-10-10 05:10:59 +00:00
mrg e8a778f4c0 call this 20140717. 2014-07-17 10:21:51 +00:00
mrg 71b444f24e rewrite much of the SSL code:
- handle errors in many places they weren't properly
- make SSL_accept() an error the main code notices
- expand bozo_ssl_err() to include bozo_ssl_warn(), bozo_clear_ssl_queue()
- remove empty bozo_ssl_flush()
2014-07-17 06:27:52 +00:00
mrg 8c06d93b7b call this bozohttpd 20140708, and add/fix a couple of CHANGES entries. 2014-07-08 14:06:17 +00:00
mrg a212be1ee8 avoid truncating a directory path when using snprintf(), but instead
detect and return an error.

found and fixed by shm@netbsd.
2014-07-08 14:01:21 +00:00
shm d1ed37e48d Handle ENAMETOOLONG to return 404 error instead of 500.
OK mrg@
2014-07-02 13:58:09 +00:00
shm ca5b33a5e8 * bozo_clean_request free(3) clean up (removed needless checks)
* HEAD method no longer returns response body on error
* fixed bug with multiple bozo_http_error calls caused by fix_url_percent

OK @mrg
2014-07-01 13:41:21 +00:00
mrg 5893f1db8f bump version, note .svg support. 2014-05-17 05:50:46 +00:00
mrg 7db440fedd - bump man page date
- strip :80 off virtual host names as they're the default
2014-02-09 12:32:32 +00:00
mrg ca768e99f0 some fixes for virtual hosting support from Rajeev V. Pillai:
- memory leaks in virtual host plugged
- ensure hr_host is only the host/port part when the request
  contains the hostname in the URI not Host: header.


also update the references to the old http/1.1 draft rev 06
to RFC 2616 (fortunately, most sections hadn't moved.)
2014-02-09 01:46:10 +00:00
mrg 496aca988c update for 2014-02-01. 2014-02-02 03:13:31 +00:00
mrg 95e8de7784 move a variable into the scope of its use, where the assignment
has already validated the pointers used.  fixes a bug reported
in private email from dogcow@.
2014-01-30 02:51:41 +00:00
mrg d1b43391bd - update CHANGES with recent changes
- update version to 20140102
- update copyrights
- use getcwd() over getwd()
- fix lean build (don't include lua)
2014-01-02 08:21:38 +00:00
mbalmer b65f3decc3 no need to check free() arguments against NULL 2013-10-12 18:46:12 +00:00
mbalmer cb23152c39 add Lua scripting support to bozohttpd, see httpd(8) for details 2013-10-12 17:24:06 +00:00