mirror of
https://github.com/git/git
synced 2024-09-30 13:45:19 +00:00
97613b9cb9
When initializing the transport helper in `transport_get()`, we allocate the name of the helper. We neither end up transferring ownership of the name, nor do we free it. The associated memory thus leaks. Fix this memory leak by freeing the string at the calling side in `transport_get()`. `transport_helper_init()` now creates its own copy of the string and thus can free it as required. An alterantive way to fix this would be to transfer ownership of the string passed into `transport_helper_init()`, which would avoid the call to xstrdup(1). But it does make for a more surprising calling convention as we do not typically transfer ownership of strings like this. Mark now-passing tests as leak free. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
43 lines
1.2 KiB
Bash
Executable file
43 lines
1.2 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description="test fetching through http proxy"
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
. "$TEST_DIRECTORY"/lib-httpd.sh
|
|
|
|
LIB_HTTPD_PROXY=1
|
|
start_httpd
|
|
|
|
test_expect_success 'setup repository' '
|
|
test_commit foo &&
|
|
git init --bare "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
|
|
git push --mirror "$HTTPD_DOCUMENT_ROOT_PATH/repo.git"
|
|
'
|
|
|
|
setup_askpass_helper
|
|
|
|
# sanity check that our test setup is correctly using proxy
|
|
test_expect_success 'proxy requires password' '
|
|
test_config_global http.proxy $HTTPD_DEST &&
|
|
test_must_fail git clone $HTTPD_URL/smart/repo.git 2>err &&
|
|
grep "error.*407" err
|
|
'
|
|
|
|
test_expect_success 'clone through proxy with auth' '
|
|
test_when_finished "rm -rf clone" &&
|
|
test_config_global http.proxy http://proxuser:proxpass@$HTTPD_DEST &&
|
|
GIT_TRACE_CURL=$PWD/trace git clone $HTTPD_URL/smart/repo.git clone &&
|
|
grep -i "Proxy-Authorization: Basic <redacted>" trace
|
|
'
|
|
|
|
test_expect_success 'clone can prompt for proxy password' '
|
|
test_when_finished "rm -rf clone" &&
|
|
test_config_global http.proxy http://proxuser@$HTTPD_DEST &&
|
|
set_askpass nobody proxpass &&
|
|
GIT_TRACE_CURL=$PWD/trace git clone $HTTPD_URL/smart/repo.git clone &&
|
|
expect_askpass pass proxuser
|
|
'
|
|
|
|
test_done
|