Commit 7707caaf by Sven Strickroth Committed by Edward Thomson

Prevent possible buffer overflow

Could happen if the path to git.exe is near to MAX_PATH and we append a longer subdir such as "share/git-core" to it.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
parent d298059e
......@@ -93,7 +93,7 @@ static int win32_find_git_in_path(git_str *buf, const wchar_t *gitexe, const wch
continue;
wcscpy(&root.path[root.len], gitexe);
if (_waccess(root.path, F_OK) == 0 && root.len > 5) {
if (_waccess(root.path, F_OK) == 0 && root.len > 5 && (root.len - 4 + wcslen(subdir) < MAX_PATH)) {
/* replace "bin\\" or "cmd\\" with subdir */
wcscpy(&root.path[root.len - 4], subdir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment