Skip to content

Commit 0fa0514

Browse files
committed
Merge branch 'maint-1.6.0' into maint-1.6.1
* maint-1.6.0: Fix buffer overflow in config parser
2 parents bc69776 + e0b3cc0 commit 0fa0514

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static char *parse_value(void)
5151

5252
for (;;) {
5353
int c = get_next_char();
54-
if (len >= sizeof(value))
54+
if (len >= sizeof(value) - 1)
5555
return NULL;
5656
if (c == '\n') {
5757
if (quote)

t/t1303-wacky-config.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setup() {
1010

1111
check() {
1212
echo "$2" >expected
13-
git config --get "$1" >actual
13+
git config --get "$1" >actual 2>&1
1414
test_cmp actual expected
1515
}
1616

@@ -40,4 +40,11 @@ test_expect_success 'make sure git config escapes section names properly' '
4040
check "$SECTION" bar
4141
'
4242

43+
LONG_VALUE=$(printf "x%01021dx a" 7)
44+
test_expect_success 'do not crash on special long config line' '
45+
setup &&
46+
git config section.key "$LONG_VALUE" &&
47+
check section.key "fatal: bad config file line 2 in .git/config"
48+
'
49+
4350
test_done

0 commit comments

Comments
 (0)