From: Jeff King Date: Thu, 24 Sep 2015 21:06:53 +0000 (-0400) Subject: entry.c: convert strcpy to xsnprintf X-Git-Tag: v2.8.3~32^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=330c8e26701c33f1d74dbe3c2692f29b5ed4ba5f;p=git entry.c: convert strcpy to xsnprintf This particular conversion is non-obvious, because nobody has passed our function the length of the destination buffer. However, the interface to checkout_entry specifies that the buffer must be at least TEMPORARY_FILENAME_LENGTH bytes long, so we can check that (meaning the existing code was not buggy, but merely worrisome to somebody reading it). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/entry.c b/entry.c index 1eda8e9471..582c40071a 100644 --- a/entry.c +++ b/entry.c @@ -96,8 +96,8 @@ static int open_output_fd(char *path, const struct cache_entry *ce, int to_tempf { int symlink = (ce->ce_mode & S_IFMT) != S_IFREG; if (to_tempfile) { - strcpy(path, symlink - ? ".merge_link_XXXXXX" : ".merge_file_XXXXXX"); + xsnprintf(path, TEMPORARY_FILENAME_LENGTH, "%s", + symlink ? ".merge_link_XXXXXX" : ".merge_file_XXXXXX"); return mkstemp(path); } else { return create_file(path, !symlink ? ce->ce_mode : 0666);