aboutsummaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-24 17:08:26 -0400
committerJunio C Hamano <gitster@pobox.com>2015-10-05 11:08:06 -0700
commiteddda371449ba925d91d04c615d084adf1b43a33 (patch)
treea19c2df8b4502c0191e5261ca12ea5d0c6f8601a /fast-import.c
parent02e32b7debbcbe5910c11a515801751b349577d7 (diff)
downloadgit-eddda371449ba925d91d04c615d084adf1b43a33.tar.gz
git-eddda371449ba925d91d04c615d084adf1b43a33.tar.xz
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 'fast-import.c')
-rw-r--r--fast-import.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fast-import.c b/fast-import.c
index cf6d8bc0c..4d01efcb9 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -703,7 +703,7 @@ static struct atom_str *to_atom(const char *s, unsigned short len)
c = pool_alloc(sizeof(struct atom_str) + len + 1);
c->str_len = len;
- strncpy(c->str_dat, s, len);
+ memcpy(c->str_dat, s, len);
c->str_dat[len] = 0;
c->next_atom = atom_table[hc];
atom_table[hc] = c;