@matheusbsbs / matheus-bagliano / commits / 3c9d0414ed
Fork 0

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 <gdb@mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Greg Brockman committed Jul 20, 2010 at 00:46 UTC 3c9d0414ed2db0167e6c828b547be8fc9f88fccc
1 file changed +2
setup.c
+2
@@ -170,6 +170,8 @@ static int is_git_directory(const char *suspect)
170 char path[PATH_MAX];
171 size_t len = strlen(suspect);
172
173 + if (PATH_MAX <= len + strlen("/objects"))
174 + die("Too long path: %.*s", 60, suspect);
175 strcpy(path, suspect);
176 if (getenv(DB_ENVIRONMENT)) {
177 if (access(getenv(DB_ENVIRONMENT), X_OK))