Re: [PATCH v6 2/2] t5560-http-backend-noserver.sh: add CONTENT_LENGTH cases
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Nov 26, 2017, 22:18 UTC
- Message-ID
- <CAPig+cROFS+3Yon2CFr-aPUGzDY4WVbU8kHbBx68O3M8k5eeug@mail.gmail.com>
- In-Reply-To
- <20171126193813.12531-3-max@max630.net>
On Sun, Nov 26, 2017 at 2:38 PM, Max Kirillov <max@max630.net> wrote:
Show 18 quoted lines
> 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 <max@max630.net>
> ---
> 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.
Show 5 quoted lines
> +} > 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
18446744073709551596Show 10 quoted lines
> + 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 > +'