@matheusbsbs / matheus-bagliano / commits / 1b0b962d77
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 1b0b962d771fb734cbf273f216b487bb58dec7b9
1 file changed +2
setup.c
+2
@@ -153,6 +153,8 @@ static int is_git_directory(const char *suspect)
153 char path[PATH_MAX];
154 size_t len = strlen(suspect);
155
156 + if (PATH_MAX <= len + strlen("/objects"))
157 + die("Too long path: %.*s", 60, suspect);
158 strcpy(path, suspect);
159 if (getenv(DB_ENVIRONMENT)) {
160 if (access(getenv(DB_ENVIRONMENT), X_OK))