summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f746bae)
raw | patch | inline | side by side (parent: f746bae)
author | Junio C Hamano <gitster@pobox.com> | |
Fri, 14 Mar 2008 05:07:18 +0000 (22:07 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 14 Mar 2008 06:56:36 +0000 (23:56 -0700) |
read-tree -m can read up to MAX_TREES, which was arbitrarily set to 8 since
August 2007 (4 is needed to deal with 2 merge-base case).
However, the updated unpack_trees() code had an advertised limit of 4
(which it enforced). In reality the code was prepared to take only 3
trees and giving 4 caused it to stomp on its stack. Rename the MAX_TREES
constant to MAX_UNPACK_TREES, move it to the unpack-trees.h common header
file, and use it from both places to avoid future confusion.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
August 2007 (4 is needed to deal with 2 merge-base case).
However, the updated unpack_trees() code had an advertised limit of 4
(which it enforced). In reality the code was prepared to take only 3
trees and giving 4 caused it to stomp on its stack. Rename the MAX_TREES
constant to MAX_UNPACK_TREES, move it to the unpack-trees.h common header
file, and use it from both places to avoid future confusion.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-read-tree.c | patch | blob | history | |
unpack-trees.c | patch | blob | history | |
unpack-trees.h | patch | blob | history |
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 160456dad13322e3547d6dc3fc91626bd3ec9c2b..e9cfd2bbc5539ee0c9c048798383b837ff63991b 100644 (file)
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
#include "dir.h"
#include "builtin.h"
-#define MAX_TREES 8
static int nr_trees;
-static struct tree *trees[MAX_TREES];
+static struct tree *trees[MAX_UNPACK_TREES];
static int list_tree(unsigned char *sha1)
{
struct tree *tree;
- if (nr_trees >= MAX_TREES)
- die("I cannot read more than %d trees", MAX_TREES);
+ if (nr_trees >= MAX_UNPACK_TREES)
+ die("I cannot read more than %d trees", MAX_UNPACK_TREES);
tree = parse_tree_indirect(sha1);
if (!tree)
return -1;
{
int i, newfd, stage = 0;
unsigned char sha1[20];
- struct tree_desc t[MAX_TREES];
+ struct tree_desc t[MAX_UNPACK_TREES];
struct unpack_trees_options opts;
memset(&opts, 0, sizeof(opts));
diff --git a/unpack-trees.c b/unpack-trees.c
index be89d52e8c55d71fe7dff2e7e2f6d6d5f8a7ca16..91649f31d6e73cac256a272b4e5eba0dc871d8ce 100644 (file)
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -123,7 +123,7 @@ static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_option
int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long df_conflicts, struct name_entry *names, struct traverse_info *info)
{
int i;
- struct tree_desc t[3];
+ struct tree_desc t[MAX_UNPACK_TREES];
struct traverse_info newinfo;
struct name_entry *p;
{
static struct cache_entry *dfc;
- if (len > 4)
- die("unpack_trees takes at most four trees");
+ if (len > MAX_UNPACK_TREES)
+ die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
memset(&state, 0, sizeof(state));
state.base_dir = "";
state.force = 1;
diff --git a/unpack-trees.h b/unpack-trees.h
index e8abbcd037167a58c816d94f4f0c617d6572d23d..50453ed20f755fea2e7138d7f01300b318f28dce 100644 (file)
--- a/unpack-trees.h
+++ b/unpack-trees.h
#ifndef UNPACK_TREES_H
#define UNPACK_TREES_H
+#define MAX_UNPACK_TREES 8
+
struct unpack_trees_options;
typedef int (*merge_fn_t)(struct cache_entry **src,