test-dump-cache-tree: avoid overflow of cache-tree name

When dumping a cache-tree, we sprintf sub-tree names directly into a fixed-size buffer, which can overflow. We can trivially fix this by converting to xsnprintf to at least notice and die. This probably should handle arbitrary-sized names, but there's not much point. It's used only by the test scripts, so the trivial fix is enough. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Sep 24, 2015 at 17:06 UTC 04724222d5aad4da48674e69aab715273f05dded
1 file changed +1 -1
test-dump-cache-tree.c
+1 -1
@@ -47,7 +47,7 @@ static int dump_cache_tree(struct cache_tree *it,
47 struct cache_tree_sub *rdwn;
48
49 rdwn = cache_tree_sub(ref, down->name);
50 - sprintf(path, "%s%.*s/", pfx, down->namelen, down->name);
50 + xsnprintf(path, sizeof(path), "%s%.*s/", pfx, down->namelen, down->name);
51 if (dump_cache_tree(down->cache_tree, rdwn->cache_tree, path))
52 errs = 1;
53 }