diff options
author | Jeff King <peff@peff.net> | 2019-07-31 06:38:18 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-08-01 22:06:40 +0200 |
commit | 37806080d7be1ab5b2fa918f6a528652596ea2c1 (patch) | |
tree | fb6f260202b9ef1feba1dac3a67d36aeb2ef98e9 /tree-walk.c | |
parent | tree-walk: drop oid from traverse_info (diff) | |
download | git-37806080d7be1ab5b2fa918f6a528652596ea2c1.tar.xz git-37806080d7be1ab5b2fa918f6a528652596ea2c1.zip |
tree-walk: use size_t consistently
We store and manipulate the cumulative traverse_info.pathlen as an
"int", which can overflow when we are fed ridiculously long pathnames
(e.g., ones at the edge of 2GB or 4GB, even if the individual tree entry
names are smaller than that). The results can be confusing, though
after some prodding I was not able to use this integer overflow to cause
an under-allocated buffer.
Let's consistently use size_t to generate and store these, and make
sure our addition doesn't overflow.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'tree-walk.c')
-rw-r--r-- | tree-walk.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tree-walk.c b/tree-walk.c index 4610f77383..70f9eb5f1b 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -168,7 +168,7 @@ int tree_entry_gently(struct tree_desc *desc, struct name_entry *entry) void setup_traverse_info(struct traverse_info *info, const char *base) { - int pathlen = strlen(base); + size_t pathlen = strlen(base); static struct traverse_info dummy; memset(info, 0, sizeof(*info)); @@ -184,7 +184,7 @@ void setup_traverse_info(struct traverse_info *info, const char *base) char *make_traverse_path(char *path, const struct traverse_info *info, const char *name, size_t namelen) { - int pathlen = info->pathlen; + size_t pathlen = info->pathlen; path[pathlen + namelen] = 0; for (;;) { |