Commit e52c2989fb6911ef74cccd87a57bffd884842d36

Edward Thomson 2021-04-04T19:46:08

repository: validate workdir path lengths

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/repository.c b/src/repository.c
index c243f1d..3544fa9 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -2702,9 +2702,9 @@ int git_repository_hashfile(
 	 * now that is not possible because git_filters_load() needs it.
 	 */
 
-	error = git_path_join_unrooted(
-		&full_path, path, git_repository_workdir(repo), NULL);
-	if (error < 0)
+	if ((error = git_path_join_unrooted(
+		&full_path, path, git_repository_workdir(repo), NULL)) < 0 ||
+	    (error = git_path_validate_workdir_buf(repo, &full_path)) < 0)
 		return error;
 
 	if (!as_path)