From 1a168e5c86d2c6cbb57429473357bdf1acdec63c Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 28 Mar 2017 15:46:56 -0400 Subject: convert unchecked snprintf into xsnprintf These calls to snprintf should always succeed, because their input is small and fixed. Let's use xsnprintf to make sure this is the case (and to make auditing for actual truncation easier). These could be candidates for turning into heap buffers, but they fall into a few broad categories that make it not worth doing: - formatting single numbers is simple enough that we can see the result should fit - the size of a sha1 is likewise well-known, and I didn't want to cause unnecessary conflicts with the ongoing process to convert these constants to GIT_MAX_HEXSZ - the interface for curl_errorstr is dictated by curl Signed-off-by: Jeff King --- submodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'submodule.c') diff --git a/submodule.c b/submodule.c index 040f4c228..c9f39ebbe 100644 --- a/submodule.c +++ b/submodule.c @@ -1402,7 +1402,7 @@ static int find_first_merges(struct object_array *result, const char *path, memset(&rev_opts, 0, sizeof(rev_opts)); /* get all revisions that merge commit a */ - snprintf(merged_revision, sizeof(merged_revision), "^%s", + xsnprintf(merged_revision, sizeof(merged_revision), "^%s", oid_to_hex(&a->object.oid)); init_revisions(&revs, NULL); rev_opts.submodule = path; -- cgit v1.2.1