tree-walk: use size_t for tree sizes
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 3 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | tree-walk: use size_t for the size of tree bufferstree-walk.c tree-walk.h | +10 | 1 reply | |
| 2/2 | tree: use size_t for the size of parsed treestree.c tree.h | +3 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] tree-walk: use size_t for tree sizes
struct tree_desc keeps the size of the tree buffer in an "unsigned int", so a tree object of 4GiB or more is truncated on all platforms, and struct tree adds another truncation on Windows, where "long" is 32 bits. The walk then sees only a prefix of the tree: it never reads past the buffer, but when the cut falls between two entries the rest of the tree silently disappears, both for commands like "git ls-tree" and for the checks in fsck_tree().
Trees that large are not something one creates by accident, but they can be crafted, and fsck is what is supposed to look at every entry of them.
1/2 moves struct tree_desc and the functions that set it up to
size_t; this is the part that matters on all platforms.
2/2 does the same for struct tree and parse_tree_buffer().
There is no test, as it would need a tree larger than 4GiB in memory; 1/2 describes how I checked the effect with a simulated 16-bit size.
This comes from the same search for truncated sizes as:
https://lore.kernel.org/git/[email protected]/
https://lore.kernel.org/git/[email protected]/
It is independent of both and merges cleanly with them. The series is based on master (b9e5cff180).
Elia Pinto (2):
tree-walk: use size_t for the size of tree buffers
tree: use size_t for the size of parsed trees
tree-walk.c | 14 +++++++------- tree-walk.h | 6 +++--- tree.c | 2 +- tree.h | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-)
base-commit: b9e5cff1803ab24582201ef059516eb16014b9d9
Signature · 1 line
2.53.0