about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2016-08-13 11:54:46 +0100
committerJohn Keeping <john@keeping.me.uk>2016-10-01 11:46:55 +0100
commite18a85b6a298feef88da8085ef16fd20ce971071 (patch)
tree617a64efc192421222549ffe7ae522f5959c9ec5
parentui-tag: clean up taginfo (diff)
downloadcgit-pink-e18a85b6a298feef88da8085ef16fd20ce971071.tar.gz
cgit-pink-e18a85b6a298feef88da8085ef16fd20ce971071.zip
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 <john@keeping.me.uk>
Diffstat (limited to '')
-rw-r--r--ui-tree.c15
1 files 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;
 		}
 	}
cwm/cwmrc?id=d249bd4693db0f5489b76985e4f873fee1ee098c&follow=1'>Fully configure and rebind cwmJune McEnroe 2021-02-07Add BintiJune McEnroe 2021-02-07Finish configuring xtermJune McEnroe 2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe 2021-02-06Set root window to black on purple snowJune McEnroe 2021-02-06Add xmodmap configurationJune McEnroe 2021-02-06Add initial OpenBSD X configurationJune McEnroe 2021-02-06Add xterm output to schemeJune McEnroe