diff options
author | Derrick Stolee <derrickstolee@github.com> | 2022-11-10 08:50:15 -0500 |
---|---|---|
committer | Derrick Stolee <derrickstolee@github.com> | 2022-11-10 08:50:41 -0500 |
commit | 6de3221debf785c328842667eb04c07c747c73a0 (patch) | |
tree | a5be723a258020246defe7f4d191429101e1dc30 /src/libgit2/commit_graph.c | |
parent | 2c4eb83ee14bca44c2442727bacd82312cbedfc5 (diff) | |
download | libgit2-6de3221debf785c328842667eb04c07c747c73a0.tar.gz |
commit_graph: use uint64_t for arithmetic
This should resolve some issues with UBSan builds by using unsigned
64-bit integers for all arithmetic until we finally convert to an offset
or size value.
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Diffstat (limited to 'src/libgit2/commit_graph.c')
-rw-r--r-- | src/libgit2/commit_graph.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libgit2/commit_graph.c b/src/libgit2/commit_graph.c index d8da1c5d3..9554fe855 100644 --- a/src/libgit2/commit_graph.c +++ b/src/libgit2/commit_graph.c @@ -200,7 +200,7 @@ int git_commit_graph_file_parse( const unsigned char *chunk_hdr; struct git_commit_graph_chunk *last_chunk; uint32_t i; - off64_t last_chunk_offset, chunk_offset, trailer_offset; + uint64_t last_chunk_offset, chunk_offset, trailer_offset; size_t checksum_size; int error; struct git_commit_graph_chunk chunk_oid_fanout = {0}, chunk_oid_lookup = {0}, @@ -236,8 +236,8 @@ int git_commit_graph_file_parse( chunk_hdr = data + sizeof(struct git_commit_graph_header); last_chunk = NULL; for (i = 0; i < hdr->chunks; ++i, chunk_hdr += 12) { - chunk_offset = ((off64_t)ntohl(*((uint32_t *)(chunk_hdr + 4)))) << 32 - | ((off64_t)ntohl(*((uint32_t *)(chunk_hdr + 8)))); + chunk_offset = ((uint64_t)ntohl(*((uint32_t *)(chunk_hdr + 4)))) << 32 + | ((uint64_t)ntohl(*((uint32_t *)(chunk_hdr + 8)))); if (chunk_offset < last_chunk_offset) return commit_graph_error("chunks are non-monotonic"); if (chunk_offset >= trailer_offset) |