Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Sep 25, 2015
1 parent 3131977 commit 0472422
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test-dump-cache-tree.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0472422

Please sign in to comment.