diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-08-22 21:34:10 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-08-22 21:34:10 +0200 |
commit | 1b01cdbf2e65331879a4668880a191dfac953761 (patch) | |
tree | 35a31e23ac1569298371f67b266067df75166cc2 /tree-walk.h | |
parent | Merge branch 'sg/t5510-test-i18ngrep-fix' (diff) | |
parent | tree-walk: harden make_traverse_path() length computations (diff) | |
download | git-1b01cdbf2e65331879a4668880a191dfac953761.tar.xz git-1b01cdbf2e65331879a4668880a191dfac953761.zip |
Merge branch 'jk/tree-walk-overflow'
Codepaths to walk tree objects have been audited for integer
overflows and hardened.
* jk/tree-walk-overflow:
tree-walk: harden make_traverse_path() length computations
tree-walk: add a strbuf wrapper for make_traverse_path()
tree-walk: accept a raw length for traverse_path_len()
tree-walk: use size_t consistently
tree-walk: drop oid from traverse_info
setup_traverse_info(): stop copying oid
Diffstat (limited to 'tree-walk.h')
-rw-r--r-- | tree-walk.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tree-walk.h b/tree-walk.h index 2a5db29e8f..abe2caf4e0 100644 --- a/tree-walk.h +++ b/tree-walk.h @@ -58,8 +58,11 @@ enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r, struct struct traverse_info { const char *traverse_path; struct traverse_info *prev; - struct name_entry name; - int pathlen; + const char *name; + size_t namelen; + unsigned mode; + + size_t pathlen; struct pathspec *pathspec; unsigned long df_conflicts; @@ -69,12 +72,17 @@ struct traverse_info { }; int get_tree_entry(struct repository *, const struct object_id *, const char *, struct object_id *, unsigned short *); -char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n); +char *make_traverse_path(char *path, size_t pathlen, const struct traverse_info *info, + const char *name, size_t namelen); +void strbuf_make_traverse_path(struct strbuf *out, + const struct traverse_info *info, + const char *name, size_t namelen); void setup_traverse_info(struct traverse_info *info, const char *base); -static inline int traverse_path_len(const struct traverse_info *info, const struct name_entry *n) +static inline size_t traverse_path_len(const struct traverse_info *info, + size_t namelen) { - return info->pathlen + tree_entry_len(n); + return st_add(info->pathlen, namelen); } /* in general, positive means "kind of interesting" */ |