summaryrefslogtreecommitdiff
path: root/src/pack.c
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-04-23 17:28:11 -0700
committerVicent Martí <tanoku@gmail.com>2012-04-23 17:28:11 -0700
commitf9f2344bd4ba6c81a96959509ba59f8563b60265 (patch)
treebb429dc1d066d433ab39076d3369cde56a48bc83 /src/pack.c
parent4795807ad5b4827ff4bdb801641ce8a4d5a8557e (diff)
parent26515e73a11b6f6c25e316ece2a6243aba7af9f5 (diff)
downloadlibgit2-f9f2344bd4ba6c81a96959509ba59f8563b60265.tar.gz
Merge pull request #632 from arrbee/win64-cleanup
Code clean up, including fixing warnings on Windows 64-bit build
Diffstat (limited to 'src/pack.c')
-rw-r--r--src/pack.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/pack.c b/src/pack.c
index b79ecf417..8d71138a2 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -165,6 +165,7 @@ static int pack_index_open(struct git_pack_file *p)
{
char *idx_name;
int error;
+ size_t name_len, offset;
if (p->index_map.data)
return 0;
@@ -172,7 +173,11 @@ static int pack_index_open(struct git_pack_file *p)
idx_name = git__strdup(p->pack_name);
GITERR_CHECK_ALLOC(idx_name);
- strcpy(idx_name + strlen(idx_name) - strlen(".pack"), ".idx");
+ name_len = strlen(idx_name);
+ offset = name_len - strlen(".pack");
+ assert(offset < name_len); /* make sure no underflow */
+
+ strncpy(idx_name + offset, ".idx", name_len - offset);
error = pack_index_check(idx_name, p);
git__free(idx_name);
@@ -501,7 +506,7 @@ git_off_t get_delta_base(
*
***********************************************************/
-static struct git_pack_file *packfile_alloc(int extra)
+static struct git_pack_file *packfile_alloc(size_t extra)
{
struct git_pack_file *p = git__calloc(1, sizeof(*p) + extra);
if (p != NULL)