Skip to content

Commit 1b0b962

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 2998138 commit 1b0b962

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
@@ -153,6 +153,8 @@ static int is_git_directory(const char *suspect)
153153
char path[PATH_MAX];
154154
size_t len = strlen(suspect);
155155

156+
if (PATH_MAX <= len + strlen("/objects"))
157+
die("Too long path: %.*s", 60, suspect);
156158
strcpy(path, suspect);
157159
if (getenv(DB_ENVIRONMENT)) {
158160
if (access(getenv(DB_ENVIRONMENT), X_OK))

0 commit comments

Comments
 (0)