Commit 69789922984d2e22f267da5f35cd64cd17c36dc0

Carlos Martín Nieto 2013-09-07T18:50:35

config: return an error when reaching the maximum include depth

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/config_file.c b/src/config_file.c
index 48a91eb..034d1d7 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -949,9 +949,10 @@ static int config_parse(diskfile_backend *cfg_file, struct reader *reader, git_c
 	int result = 0;
 	khiter_t pos;
 
-	/* FIXME: should we return an error? */
-	if (depth >= MAX_INCLUDE_DEPTH)
-		return 0;
+	if (depth >= MAX_INCLUDE_DEPTH) {
+		giterr_set(GITERR_CONFIG, "Maximum config include depth reached");
+		return -1;
+	}
 
 	/* Initialize the reading position */
 	reader->read_ptr = reader->buffer.ptr;