Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-25 00:06:03 +0300
committerJunio C Hamano <gitster@pobox.com>2015-09-25 20:18:18 +0300
commit04724222d5aad4da48674e69aab715273f05dded (patch)
treecd8923223008e3c6a652d5b6f8bb393fef7956ce /test-dump-cache-tree.c
parent3131977de1476185209d4d56a0494f5b30ee5557 (diff)
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>
Diffstat (limited to 'test-dump-cache-tree.c')
-rw-r--r--test-dump-cache-tree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/test-dump-cache-tree.c b/test-dump-cache-tree.c
index 54c0872fcb..bb53c0aa65 100644
--- a/test-dump-cache-tree.c
+++ b/test-dump-cache-tree.c
@@ -47,7 +47,7 @@ static int dump_cache_tree(struct cache_tree *it,
struct cache_tree_sub *rdwn;
rdwn = cache_tree_sub(ref, down->name);
- sprintf(path, "%s%.*s/", pfx, down->namelen, down->name);
+ xsnprintf(path, sizeof(path), "%s%.*s/", pfx, down->namelen, down->name);
if (dump_cache_tree(down->cache_tree, rdwn->cache_tree, path))
errs = 1;
}