- fix a bug in cgi processing. from Dennis Lindroos.

- add a testcase for this, and expand test-simple to handle additional
  args to bozohttpd for eg, cgi-bin setting.
- fix objdir bugs in the testsuite.
This commit is contained in:
mrg 2017-01-31 14:33:54 +00:00
parent 8dcd50a6a0
commit 2c19cec69e
8 changed files with 53 additions and 22 deletions

View File

@ -1,7 +1,12 @@
$NetBSD: CHANGES,v 1.24 2016/08/20 00:36:41 mrg Exp $
$NetBSD: CHANGES,v 1.25 2017/01/31 14:33:54 mrg Exp $
changes in bozohttpd 20170201:
o fix an infinite loop in cgi processing
o fixes and clean up for the testsuite
o no longer sends encoding header for compressed formats
changes in bozohttpd 20160517:
o add a bozo_get_version() function which returns the version number
o add a bozo_get_version() function which returns the version number
changes in bozohttpd 20160415:
o add search-word support for CGI

View File

@ -1,4 +1,4 @@
/* $NetBSD: cgi-bozo.c,v 1.35 2016/04/24 18:24:47 christos Exp $ */
/* $NetBSD: cgi-bozo.c,v 1.36 2017/01/31 14:33:54 mrg Exp $ */
/* $eterna: cgi-bozo.c,v 1.40 2011/11/18 09:21:15 mrg Exp $ */
@ -235,7 +235,8 @@ parse_search_string(bozo_httpreq_t *request, const char *query, size_t *args_len
*/
*args_len = 1;
/* count '+' in str */
for (s = str; (s = strchr(s, '+')); (*args_len)++);
for (s = str; (s = strchr(s, '+')); (*args_len)++)
s++;
args = bozomalloc(httpd, sizeof(*args) * (*args_len + 1));

View File

@ -1,6 +1,7 @@
# $eterna: Makefile,v 1.14 2009/05/22 21:51:39 mrg Exp $
SIMPLETESTS= t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
CGITESTS= t11
BIGFILETESTS= partial4000 partial8000
BOZOHTTPD?= ../bozohttpd
@ -22,11 +23,16 @@ clean:
rm -f tmp.$$a.out tmp.$$a.err; \
done
check: check-simple check-bigfile
check: check-simple check-cgi check-bigfile
check-simple:
.for a in $(SIMPLETESTS)
${SILENT}$(.CURDIR)/test-simple "$a" "${BOZOHTTPD}" "${DATA}" "${VERBOSE}"
${SILENT}$(.CURDIR)/test-simple "$a" "${BOZOHTTPD}" "${DATA}" "${.CURDIR}" "${VERBOSE}"
.endfor
check-cgi:
.for a in $(CGITESTS)
${SILENT}$(.CURDIR)/test-simple "$a" "${BOZOHTTPD}" "${DATA}" "${.CURDIR}" "${VERBOSE}" -c "${.CURDIR}/cgi-bin"
.endfor
check-bigfile:

View File

View File

@ -0,0 +1,3 @@
GET /cgi-bin/echo.bat?&dir+c:\\ HTTP/1.1
Host:

View File

@ -0,0 +1 @@
HTTP/1.1 200 OK

View File

@ -1,5 +1,5 @@
#! /bin/sh
# $NetBSD: test-bigfile,v 1.3 2016/09/23 16:55:56 schmonz Exp $
# $NetBSD: test-bigfile,v 1.4 2017/01/31 14:33:54 mrg Exp $
test="$1" # partial4000 or partial8000
bozohttpd="$2"
@ -7,30 +7,35 @@ wget="$3"
datadir="$4"
verbose="$5"
tmperr="tmp.$test.err"
if [ "yes" = "$verbose" ]; then
echo "Running test $test"
else
exec 2>tmp.$test.err
exec 2>"$tmperr"
fi
bozotestport=11111
# copy beginning file
cp ${datadir}/bigfile.${test} ./bigfile
cp "${datadir}/bigfile.${test}" ./bigfile
# fire up bozohttpd
${bozohttpd} -b -b -I ${bozotestport} -n -s -f ${datadir} &
${bozohttpd} -b -b -I ${bozotestport} -n -s -f "${datadir}" &
bozopid=$!
${wget} -c http://localhost:${bozotestport}/bigfile
"${wget}" -c http://localhost:${bozotestport}/bigfile
kill -9 $bozopid
if cmp ./bigfile ${datadir}/bigfile; then
if cmp ./bigfile "${datadir}/bigfile"; then
rm -f ./bigfile
exit 0
else
rm -f ./bigfile
[ "yes" = "$verbose" ] || echo "Failed test $test: `cat tmp.$test.err`"
if [ "yes" = "$verbose" ]; then
echo "Failed test $test:"
cat "$tmperr"
fi
exit 1
fi

View File

@ -1,23 +1,33 @@
#! /bin/sh
# $NetBSD: test-simple,v 1.3 2016/12/27 12:09:19 schmonz Exp $
# $NetBSD: test-simple,v 1.4 2017/01/31 14:33:54 mrg Exp $
test="$1"
bozohttpd="$2"
datadir="$3"
verbose="$4"
test="$1"; shift
bozohttpd="$1"; shift
datadir="$1"; shift
curdir="$1"; shift
verbose="$1"; shift
in="$curdir/$test.in"
out="$curdir/$test.out"
tmpout="tmp.$test.out"
tmperr="tmp.$test.err"
if [ "yes" = "$verbose" ]; then
echo "Running test $test"
else
exec 2>tmp.$test.err
exec 2>"$tmperr"
fi
bozotestport=11111
${bozohttpd} ${datadir} < $test.in > tmp.$test.out
if ./html_cmp cmp $test.out tmp.$test.out; then
${bozohttpd} "$@" "${datadir}" < "$in" > "$tmpout"
if "$curdir/html_cmp" cmp "$out" "$tmpout"; then
exit 0
else
[ "yes" = "$verbose" ] || echo "Failed test $test: `cat tmp.$test.err; echo; ./html_cmp diff $test.out tmp.$test.out`"
if [ "yes" = "$verbose" ]; then
echo "Failed test $test:"
cat "$tmperr"
$curdir/html_cmp diff "$out" "$tmpout"
fi
exit 1
fi