Thread (50 messages) flat view 50 messages, 6 authors, 2018-08-04

Re: [PATCH v6 2/2] t5560-http-backend-noserver.sh: add CONTENT_LENGTH cases

From: Eric Sunshine <hidden>
Date: 2017-11-26 22:19:01

On Sun, Nov 26, 2017 at 2:38 PM, Max Kirillov [off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 fix into ssize_t.

Signed-off-by: Max Kirillov <redacted>
---
diff --git a/t/helper/test-print-values.c b/t/helper/test-print-values.c
@@ -0,0 +1,10 @@
+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;
Perhaps this should return 0 only if it gets the expected argument
"(size_t)(-20)", and return an error otherwise.
quoted hunk ↗ jump to hunk
+}
diff --git 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' '
+test_expect_success 'CONTENT_LENGTH overflow ssite_t' '
+       NOT_FIT_IN_SSIZE=`"$GIT_BUILD_DIR/t/helper/test-print-values" "(size_t)(-20)"` &&
Rather than introducing a new 'test' program, would it be possible to
get by with just using 'printf' from the shell?

    % printf "%zu\n" -20
    18446744073709551596
+       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
+'
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help