vendor/libgit2/src/libgit2/index.c in rugged-1.5.1 vs vendor/libgit2/src/libgit2/index.c in rugged-1.6.2
- old
+ new
@@ -72,11 +72,11 @@
uint32_t ino;
uint32_t mode;
uint32_t uid;
uint32_t gid;
uint32_t file_size;
- unsigned char oid[GIT_OID_RAWSZ];
+ unsigned char oid[GIT_OID_SHA1_SIZE];
uint16_t flags;
char path[1]; /* arbitrary length */
};
struct entry_long {
@@ -86,11 +86,11 @@
uint32_t ino;
uint32_t mode;
uint32_t uid;
uint32_t gid;
uint32_t file_size;
- unsigned char oid[GIT_OID_RAWSZ];
+ unsigned char oid[GIT_OID_SHA1_SIZE];
uint16_t flags;
uint16_t flags_extended;
char path[1]; /* arbitrary length */
};
@@ -2352,18 +2352,20 @@
/* read up to 3 OIDs for stage entries */
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 */
if (git_vector_insert(&index->reuc, lost) < 0)
return -1;
@@ -2480,11 +2482,11 @@
entry.uid = ntohl(source.uid);
entry.gid = ntohl(source.gid);
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) {
uint16_t flags_raw;
size_t flags_offset;
@@ -2803,11 +2805,11 @@
ondisk.ino = htonl(entry->ino);
ondisk.mode = htonl(entry->mode);
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) {
const size_t path_offset = offsetof(struct entry_long, path);
struct entry_long ondisk_ext;
@@ -2966,10 +2968,10 @@
(error = git_str_put(reuc_buf, "\0", 1)) < 0)
return error;
}
for (i = 0; i < 3; i++) {
- if (reuc->mode[i] && (error = git_str_put(reuc_buf, (char *)&reuc->oid[i].id, GIT_OID_RAWSZ)) < 0)
+ if (reuc->mode[i] && (error = git_str_put(reuc_buf, (char *)&reuc->oid[i].id, GIT_OID_SHA1_SIZE)) < 0)
return error;
}
return 0;
}