Skip to content

Commit cc33752

Browse files
committed
Fix counting issue, checksum matches now (#293)
1 parent 9ffd523 commit cc33752

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

git-index/src/extension.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod end_of_index_entry {
2121
}
2222

2323
let start_of_eoie = data.len() - EndOfIndexEntry::SIZE_WITH_HEADER - hash_len;
24-
let ext_data = &data[start_of_eoie..][..hash_len];
24+
let ext_data = &data[start_of_eoie..data.len() - hash_len];
2525

2626
let (signature, ext_size, ext_data) = extension::decode_header(ext_data);
2727
if signature != EndOfIndexEntry::SIGNATURE || ext_size as usize != EndOfIndexEntry::SIZE {
@@ -32,7 +32,6 @@ mod end_of_index_entry {
3232
let offset = read_u32(offset) as usize;
3333
if offset < header::SIZE || offset > start_of_eoie || checksum.len() != git_hash::Kind::Sha1.len_in_bytes()
3434
{
35-
dbg!("checksum too small");
3635
return None;
3736
}
3837

@@ -49,8 +48,9 @@ mod end_of_index_entry {
4948
if hasher.digest() != checksum {
5049
return None;
5150
}
51+
// The last-to-this chunk ends where ours starts
5252
if last_chunk
53-
.map(|s| s.as_ptr_range() != ext_data.as_ptr_range())
53+
.map(|s| s.as_ptr_range().end != (&data[start_of_eoie]) as *const _)
5454
.unwrap_or(true)
5555
{
5656
return None;

0 commit comments

Comments
 (0)