summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.c5
-rwxr-xr-xt/t1300-repo-config.sh6
2 files changed, 11 insertions, 0 deletions
diff --git a/config.c b/config.c
index b6082f597c..c08c66890f 100644
--- a/config.c
+++ b/config.c
@@ -661,6 +661,11 @@ int git_config_set_multivar(const char* key, const char* value,
goto out_free;
}
c = tolower(c);
+ } else if (c == '\n') {
+ fprintf(stderr, "invalid key (newline): %s\n", key);
+ free(store.key);
+ ret = 1;
+ goto out_free;
}
store.key[i] = c;
}
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 60acdd368b..eb7455ba21 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -418,5 +418,11 @@ EOF
test_expect_success 'quoting' 'cmp .git/config expect'
+test_expect_failure 'key with newline' 'git repo-config key.with\\\
+newline 123'
+
+test_expect_success 'value with newline' 'git repo-config key.sub value.with\\\
+newline'
+
test_done