summaryrefslogtreecommitdiff
path: root/src/libgit2/index.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libgit2/index.c')
-rw-r--r--src/libgit2/index.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/libgit2/index.c b/src/libgit2/index.c
index 977820a4e..91d74a01e 100644
--- a/src/libgit2/index.c
+++ b/src/libgit2/index.c
@@ -2354,14 +2354,16 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
for (i = 0; i < 3; i++) {
if (!lost->mode[i])
continue;
- if (size < 20) {
+ if (size < GIT_OID_SHA1_SIZE) {
index_entry_reuc_free(lost);
return index_error_invalid("reading reuc entry oid");
}
- git_oid_fromraw(&lost->oid[i], (const unsigned char *) buffer);
- size -= 20;
- buffer += 20;
+ if (git_oid_fromraw(&lost->oid[i], (const unsigned char *) buffer, GIT_OID_SHA1) < 0)
+ return -1;
+
+ size -= GIT_OID_SHA1_SIZE;
+ buffer += GIT_OID_SHA1_SIZE;
}
/* entry was read successfully - insert into reuc vector */
@@ -2482,7 +2484,7 @@ static int read_entry(
entry.file_size = ntohl(source.file_size);
entry.flags = ntohs(source.flags);
- if (git_oid_fromraw(&entry.id, source.oid) < 0)
+ if (git_oid_fromraw(&entry.id, source.oid, GIT_OID_SHA1) < 0)
return -1;
if (entry.flags & GIT_INDEX_ENTRY_EXTENDED) {
@@ -2805,7 +2807,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
ondisk.uid = htonl(entry->uid);
ondisk.gid = htonl(entry->gid);
ondisk.file_size = htonl((uint32_t)entry->file_size);
- git_oid_raw_cpy(ondisk.oid, entry->id.id);
+ git_oid_raw_cpy(ondisk.oid, entry->id.id, GIT_OID_SHA1_SIZE);
ondisk.flags = htons(entry->flags);
if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {