Skip to content

Commit 3c9d041

Browse files
Greg Brockmangitster
authored andcommitted
Check size of path buffer before writing into it
This prevents a buffer overrun that could otherwise be triggered by creating a file called '.git' with contents gitdir: (something really long) Signed-off-by: Greg Brockman <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c173dad commit 3c9d041

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

setup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ static int is_git_directory(const char *suspect)
170170
char path[PATH_MAX];
171171
size_t len = strlen(suspect);
172172

173+
if (PATH_MAX <= len + strlen("/objects"))
174+
die("Too long path: %.*s", 60, suspect);
173175
strcpy(path, suspect);
174176
if (getenv(DB_ENVIRONMENT)) {
175177
if (access(getenv(DB_ENVIRONMENT), X_OK))

0 commit comments

Comments
 (0)