Module Name:    src
Committed By:   mrg
Date:           Tue Jan 31 14:33:54 UTC 2017

Modified Files:
        src/libexec/httpd: CHANGES cgi-bozo.c
        src/libexec/httpd/testsuite: Makefile test-bigfile test-simple
Added Files:
        src/libexec/httpd/testsuite: t11.in t11.out
        src/libexec/httpd/testsuite/cgi-bin: empty

Log Message:
- 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.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/libexec/httpd/CHANGES
cvs rdiff -u -r1.35 -r1.36 src/libexec/httpd/cgi-bozo.c
cvs rdiff -u -r1.6 -r1.7 src/libexec/httpd/testsuite/Makefile
cvs rdiff -u -r0 -r1.1 src/libexec/httpd/testsuite/t11.in \
    src/libexec/httpd/testsuite/t11.out
cvs rdiff -u -r1.3 -r1.4 src/libexec/httpd/testsuite/test-bigfile \
    src/libexec/httpd/testsuite/test-simple
cvs rdiff -u -r0 -r1.1 src/libexec/httpd/testsuite/cgi-bin/empty

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/httpd/CHANGES
diff -u src/libexec/httpd/CHANGES:1.24 src/libexec/httpd/CHANGES:1.25
--- src/libexec/httpd/CHANGES:1.24	Sat Aug 20 00:36:41 2016
+++ src/libexec/httpd/CHANGES	Tue Jan 31 14:33:54 2017
@@ -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

Index: src/libexec/httpd/cgi-bozo.c
diff -u src/libexec/httpd/cgi-bozo.c:1.35 src/libexec/httpd/cgi-bozo.c:1.36
--- src/libexec/httpd/cgi-bozo.c:1.35	Sun Apr 24 18:24:47 2016
+++ src/libexec/httpd/cgi-bozo.c	Tue Jan 31 14:33:54 2017
@@ -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 *requ
 	 */
 	*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));
  

Index: src/libexec/httpd/testsuite/Makefile
diff -u src/libexec/httpd/testsuite/Makefile:1.6 src/libexec/httpd/testsuite/Makefile:1.7
--- src/libexec/httpd/testsuite/Makefile:1.6	Fri Sep 23 16:55:56 2016
+++ src/libexec/httpd/testsuite/Makefile	Tue Jan 31 14:33:54 2017
@@ -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:

Index: src/libexec/httpd/testsuite/test-bigfile
diff -u src/libexec/httpd/testsuite/test-bigfile:1.3 src/libexec/httpd/testsuite/test-bigfile:1.4
--- src/libexec/httpd/testsuite/test-bigfile:1.3	Fri Sep 23 16:55:56 2016
+++ src/libexec/httpd/testsuite/test-bigfile	Tue Jan 31 14:33:54 2017
@@ -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
Index: src/libexec/httpd/testsuite/test-simple
diff -u src/libexec/httpd/testsuite/test-simple:1.3 src/libexec/httpd/testsuite/test-simple:1.4
--- src/libexec/httpd/testsuite/test-simple:1.3	Tue Dec 27 12:09:19 2016
+++ src/libexec/httpd/testsuite/test-simple	Tue Jan 31 14:33:54 2017
@@ -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

Added files:

Index: src/libexec/httpd/testsuite/t11.in
diff -u /dev/null src/libexec/httpd/testsuite/t11.in:1.1
--- /dev/null	Tue Jan 31 14:33:54 2017
+++ src/libexec/httpd/testsuite/t11.in	Tue Jan 31 14:33:54 2017
@@ -0,0 +1,3 @@
+GET /cgi-bin/echo.bat?&dir+c:\\ HTTP/1.1
+Host: 
+
Index: src/libexec/httpd/testsuite/t11.out
diff -u /dev/null src/libexec/httpd/testsuite/t11.out:1.1
--- /dev/null	Tue Jan 31 14:33:54 2017
+++ src/libexec/httpd/testsuite/t11.out	Tue Jan 31 14:33:54 2017
@@ -0,0 +1 @@
+HTTP/1.1 200 OK


Reply via email to