Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/tree.c b/tree.c
index c745462f96..990f9c9854 100644
--- a/tree.c
+++ b/tree.c
@@ -10,11 +10,13 @@
#include "alloc.h"
#include "tree-walk.h"
#include "repository.h"
+#include "environment.h"
const char *tree_type = "tree";
int read_tree_at(struct repository *r,
struct tree *tree, struct strbuf *base,
+ int depth,
const struct pathspec *pathspec,
read_tree_fn_t fn, void *context)
{
@@ -24,6 +26,9 @@ int read_tree_at(struct repository *r,
int len, oldlen = base->len;
enum interesting retval = entry_not_interesting;
+ if (depth > max_allowed_tree_depth)
+ return error("exceeded maximum allowed tree depth");
+
if (parse_tree(tree))
return -1;
@@ -74,7 +79,7 @@ int read_tree_at(struct repository *r,
strbuf_add(base, entry.path, len);
strbuf_addch(base, '/');
retval = read_tree_at(r, lookup_tree(r, &oid),
- base, pathspec,
+ base, depth + 1, pathspec,
fn, context);
strbuf_setlen(base, oldlen);
if (retval)
@@ -89,7 +94,7 @@ int read_tree(struct repository *r,
read_tree_fn_t fn, void *context)
{
struct strbuf sb = STRBUF_INIT;
- int ret = read_tree_at(r, tree, &sb, pathspec, fn, context);
+ int ret = read_tree_at(r, tree, &sb, 0, pathspec, fn, context);
strbuf_release(&sb);
return ret;
}