diff options
| author | Taylor Blau <me@ttaylorr.com> | 2023-04-14 11:46:59 -0400 |
|---|---|---|
| committer | Johannes Schindelin <johannes.schindelin@gmx.de> | 2023-04-17 21:15:42 +0200 |
| commit | 528290f8c61222433a8cf02fb7cfffa8438432b4 (patch) | |
| tree | e3512cac669507c04ca5378f215230b8e7b26a78 /t | |
| parent | 4fe5d0b10afdc9ac5b703605b8d84d1ce5d71e87 (diff) | |
| parent | 3bb3d6bac5f2b496dfa2862dc1a84cbfa9b4449a (diff) | |
| download | git-528290f8c61222433a8cf02fb7cfffa8438432b4.tar.xz | |
Merge branch 'tb/config-copy-or-rename-in-file-injection'
Avoids issues with renaming or deleting sections with long lines, where
configuration values may be interpreted as sections, leading to
configuration injection. Addresses CVE-2023-29007.
* tb/config-copy-or-rename-in-file-injection:
config.c: disallow overly-long lines in `copy_or_rename_section_in_file()`
config.c: avoid integer truncation in `copy_or_rename_section_in_file()`
config: avoid fixed-sized buffer when renaming/deleting a section
t1300: demonstrate failure when renaming sections with long lines
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 't')
| -rwxr-xr-x | t/t1300-config.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 1a4156c704..de564cb8e5 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -613,6 +613,36 @@ test_expect_success 'renaming to bogus section is rejected' ' test_must_fail git config --rename-section branch.zwei "bogus name" ' +test_expect_success 'renaming a section with a long line' ' + { + printf "[b]\\n" && + printf " c = d %1024s [a] e = f\\n" " " && + printf "[a] g = h\\n" + } >y && + git config -f y --rename-section a xyz && + test_must_fail git config -f y b.e +' + +test_expect_success 'renaming an embedded section with a long line' ' + { + printf "[b]\\n" && + printf " c = d %1024s [a] [foo] e = f\\n" " " && + printf "[a] g = h\\n" + } >y && + git config -f y --rename-section a xyz && + test_must_fail git config -f y foo.e +' + +test_expect_success 'renaming a section with an overly-long line' ' + { + printf "[b]\\n" && + printf " c = d %525000s e" " " && + printf "[a] g = h\\n" + } >y && + test_must_fail git config -f y --rename-section a xyz 2>err && + test_i18ngrep "refusing to work with overly long line in .y. on line 2" err +' + cat >> .git/config << EOF [branch "zwei"] a = 1 [branch "vier"] EOF |
