Fix incorrect string indexing in Git config parsing (#17832)

This commit is contained in:
Dylan Conway
2025-03-01 03:10:53 -08:00
committed by GitHub
parent 99cbdfb004
commit a620db7025

View File

@@ -110,7 +110,7 @@ const SloppyGlobalGitConfig = struct {
}
} else {
if (!found_askpass) {
if (line.len > "core.askpass".len and strings.eqlCaseInsensitiveASCIIIgnoreLength(line[0.."core.askpass".len], "core.askpass") and switch (line["sshCommand".len]) {
if (line.len > "core.askpass".len and strings.eqlCaseInsensitiveASCIIIgnoreLength(line[0.."core.askpass".len], "core.askpass") and switch (line["core.askpass".len]) {
' ', '\t', '=' => true,
else => false,
}) {
@@ -120,7 +120,7 @@ const SloppyGlobalGitConfig = struct {
}
if (!found_ssh_command) {
if (line.len > "core.sshCommand".len and strings.eqlCaseInsensitiveASCIIIgnoreLength(line[0.."core.sshCommand".len], "core.sshCommand") and switch (line["sshCommand".len]) {
if (line.len > "core.sshCommand".len and strings.eqlCaseInsensitiveASCIIIgnoreLength(line[0.."core.sshCommand".len], "core.sshCommand") and switch (line["core.sshCommand".len]) {
' ', '\t', '=' => true,
else => false,
}) {