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
path: root/tag.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-25 00:08:26 +0300
committerJunio C Hamano <gitster@pobox.com>2015-10-05 21:08:06 +0300
commiteddda371449ba925d91d04c615d084adf1b43a33 (patch)
treea19c2df8b4502c0191e5261ca12ea5d0c6f8601a /tag.c
parent02e32b7debbcbe5910c11a515801751b349577d7 (diff)
convert strncpy to memcpy
strncpy is known to be a confusing function because of its termination semantics. These calls are all correct, but it takes some examination to see why. In particular, every one of them expects to copy up to the length limit, and then makes some arrangement for terminating the result. We can just use memcpy, along with noting explicitly how the result is terminated (if it is not already obvious). That should make it more clear to a reader that we are doing the right thing. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'tag.c')
-rw-r--r--tag.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tag.c b/tag.c
index 5b0ac62ed8..5b2a06d92b 100644
--- a/tag.c
+++ b/tag.c
@@ -82,7 +82,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
nl = memchr(bufptr, '\n', tail - bufptr);
if (!nl || sizeof(type) <= (nl - bufptr))
return -1;
- strncpy(type, bufptr, nl - bufptr);
+ memcpy(type, bufptr, nl - bufptr);
type[nl - bufptr] = '\0';
bufptr = nl + 1;