summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kirillov <max@max630.net>2017-11-26 21:38:13 +0200
committerJunio C Hamano <gitster@pobox.com>2017-11-27 13:05:50 +0900
commit05f02fd4a9ccf7ba2209be18ae9abaccd9dae767 (patch)
treea93aa333b40943fdf7f92440f5d383b7b7a9fdb4
parentbc93acb9638052e78f7f0e2e781a093abbf8d124 (diff)
downloadgit-05f02fd4a9ccf7ba2209be18ae9abaccd9dae767.tar.gz
t5560-http-backend-noserver.sh: add CONTENT_LENGTH cases
Add tests for cases: * CONTENT_LENGTH is set, script's stdin has more data. (Failure would make it read GIT_HTTP_MAX_REQUEST_BUFFER bytes from /dev/zero and fail. It does not seem to cause any performance issues with the default value of GIT_HTTP_MAX_REQUEST_BUFFER.) * CONTENT_LENGTH is specified to a value which does not fit into ssize_t. Signed-off-by: Max Kirillov <max@max630.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Makefile1
-rw-r--r--t/helper/test-print-values.c10
-rwxr-xr-xt/t5560-http-backend-noserver.sh30
3 files changed, 41 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index ee9d5eb11e..e61f8319b3 100644
--- a/Makefile
+++ b/Makefile
@@ -661,6 +661,7 @@ TEST_PROGRAMS_NEED_X += test-mktemp
TEST_PROGRAMS_NEED_X += test-online-cpus
TEST_PROGRAMS_NEED_X += test-parse-options
TEST_PROGRAMS_NEED_X += test-path-utils
+TEST_PROGRAMS_NEED_X += test-print-values
TEST_PROGRAMS_NEED_X += test-prio-queue
TEST_PROGRAMS_NEED_X += test-read-cache
TEST_PROGRAMS_NEED_X += test-write-cache
diff --git a/t/helper/test-print-values.c b/t/helper/test-print-values.c
new file mode 100644
index 0000000000..8f7e5af319
--- /dev/null
+++ b/t/helper/test-print-values.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <string.h>
+
+int cmd_main(int argc, const char **argv)
+{
+ if (argc == 2 && strcmp(argv[1], "(size_t)(-20)") == 0)
+ printf("%zu", (ssize_t)(-20));
+
+ return 0;
+}
diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh
index 9fafcf1945..f452090216 100755
--- a/t/t5560-http-backend-noserver.sh
+++ b/t/t5560-http-backend-noserver.sh
@@ -71,4 +71,34 @@ test_expect_success 'http-backend blocks bad PATH_INFO' '
expect_aliased 1 //domain/data.txt
'
+# overrides existing definition for further cases
+run_backend() {
+ CONTENT_LENGTH="${#2}" && export CONTENT_LENGTH &&
+ ( echo "$2" && cat /dev/zero ) |
+ QUERY_STRING="${1#*[?]}" \
+ PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%[?]*}" \
+ git http-backend >act.out 2>act.err
+}
+
+test_expect_success 'CONTENT_LENGTH set and infinite input' '
+ config http.uploadpack true &&
+ GET info/refs?service=git-upload-pack "200 OK" &&
+ ! grep "fatal:.*" act.err &&
+ POST git-upload-pack 0000 "200 OK" &&
+ ! grep "fatal:.*" act.err
+'
+
+test_expect_success 'CONTENT_LENGTH overflow ssite_t' '
+ NOT_FIT_IN_SSIZE=`"$GIT_BUILD_DIR/t/helper/test-print-values" "(size_t)(-20)"` &&
+ env \
+ CONTENT_TYPE=application/x-git-upload-pack-request \
+ QUERY_STRING=/repo.git/git-upload-pack \
+ PATH_TRANSLATED="$PWD"/.git/git-upload-pack \
+ GIT_HTTP_EXPORT_ALL=TRUE \
+ REQUEST_METHOD=POST \
+ CONTENT_LENGTH="$NOT_FIT_IN_SSIZE" \
+ git http-backend </dev/zero >/dev/null 2>err &&
+ grep -q "fatal:.*CONTENT_LENGTH" err
+'
+
test_done