mirror of
https://github.com/git/git
synced 2024-11-04 16:17:49 +00:00
c75841687b
There are two memory leaks in "shell.c". The first one in `run_shell()` is trivial and fixed without further explanation. The second one in `cmd_main()` happens because we overwrite the `prog` variable, which contains an allocated string. In fact though, the memory pointed to by that variable is still in use because we use `split_cmdline()`, which may create pointers into the middle of that string. But as we do not have a direct pointer to the head of the allocated string anymore, we get a complaint by the leak checker. Address this by not overwriting the `prog` pointer. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
39 lines
905 B
Bash
Executable file
39 lines
905 B
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='git shell tests'
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'shell allows upload-pack' '
|
|
printf 0000 >input &&
|
|
git upload-pack . <input >expect &&
|
|
git shell -c "git-upload-pack $SQ.$SQ" <input >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'shell forbids other commands' '
|
|
test_must_fail git shell -c "git config foo.bar baz"
|
|
'
|
|
|
|
test_expect_success 'shell forbids interactive use by default' '
|
|
test_must_fail git shell
|
|
'
|
|
|
|
test_expect_success 'shell allows interactive command' '
|
|
mkdir git-shell-commands &&
|
|
write_script git-shell-commands/ping <<-\EOF &&
|
|
echo pong
|
|
EOF
|
|
echo pong >expect &&
|
|
echo ping | git shell >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'shell complains of overlong commands' '
|
|
perl -e "print \"a\" x 2**12 for (0..2**19)" |
|
|
test_must_fail git shell 2>err &&
|
|
grep "too long" err
|
|
'
|
|
|
|
test_done
|