From e18a85b6a298feef88da8085ef16fd20ce971071 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Sat, 13 Aug 2016 11:54:46 +0100 Subject: ui-tree: remove a fixed size buffer As libgit.a moves away from using fixed size buffers, there is no guarantee that PATH_MAX is sufficient for all of the paths in a Git tree, so we should use a dynamically sized buffer here. Coverity-Id: 141884 Signed-off-by: John Keeping --- ui-tree.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ui-tree.c b/ui-tree.c index 5c31e6a..b98a7f0 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -324,22 +324,25 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base, const char *pathname, unsigned mode, int stage, void *cbdata) { struct walk_tree_context *walk_tree_ctx = cbdata; - static char buffer[PATH_MAX]; if (walk_tree_ctx->state == 0) { - memcpy(buffer, base->buf, base->len); - strcpy(buffer + base->len, pathname); - if (strcmp(walk_tree_ctx->match_path, buffer)) + struct strbuf buffer = STRBUF_INIT; + + strbuf_addbuf(&buffer, base); + strbuf_addstr(&buffer, pathname); + if (strcmp(walk_tree_ctx->match_path, buffer.buf)) return READ_TREE_RECURSIVE; if (S_ISDIR(mode)) { walk_tree_ctx->state = 1; - set_title_from_path(buffer); + set_title_from_path(buffer.buf); + strbuf_release(&buffer); ls_head(); return READ_TREE_RECURSIVE; } else { walk_tree_ctx->state = 2; - print_object(sha1, buffer, pathname, walk_tree_ctx->curr_rev); + print_object(sha1, buffer.buf, pathname, walk_tree_ctx->curr_rev); + strbuf_release(&buffer); return 0; } } -- cgit 1.4.1 value='committer'>committer
Commit message (Expand)Author
2020-01-15Move mksh to Linux-onlyJune McEnroe
2020-01-15Remove gpg from install.shJune McEnroe
2020-01-15Remove git from install.shJune McEnroe
2020-01-14Highlight single-char variables nested in make interpolationsJune McEnroe
2020-01-08Set Bl -column tables to 100% widthJune McEnroe
2020-01-08Don't add dt margins to Bl-compact listsJune McEnroe
2020-01-08Use mandoc -T html for about-filterJune McEnroe
2020-01-05Add The Book of FloraJune McEnroe
2020-01-04Replace gr alias with git resetJune McEnroe
2020-01-03Remove shotty -c flag from upJune McEnroe
2020-01-03Add Darling Don't CryJune McEnroe
2020-01-01Update license header templates for the new yearJune McEnroe
2019-12-26Add \S to sort inside bracesJune McEnroe
2019-12-23Reformat music.txtJune McEnroe
2019-12-23Rename music.md to music.txtJune McEnroe
2019-12-23Add DO YOU DOUBT ME TRAITORJune McEnroe
2019-12-22Add license header to cgit CSSJune McEnroe
2019-12-22Add The Book of EttaJune McEnroe
2019-12-21Revert "Add first working version of imbox"June McEnroe
2019-12-21Add first working version of imboxJune McEnroe
2019-12-20Respect mailmap in gl pretty formatJune McEnroe
2019-12-20Set LANG in cgit filtersJune McEnroe
2019-12-20Source .editrc before applying -v or -eJune McEnroe
2019-12-20Disable signing commitsJune McEnroe
2019-12-19Ignore about-filterJune McEnroe
2019-12-19Fix matching make tags with no sourcesJune McEnroe
2019-12-19Avoid matching := assignments as tagsJune McEnroe
2019-12-18Hide line numbers when rendering mdocJune McEnroe
2019-12-18Customize cgit CSSJune McEnroe
2019-12-18Use :target rather than :focus pseudo-classJune McEnroe
2019-12-18Copy cgit auxiliary binaries properlyJune McEnroe
2019-12-18Add git.causal.agency cgit configJune McEnroe
2019-12-18Bail from hi if input is binaryJune McEnroe
2019-12-16Post "cgit setup"June McEnroe