Skip to content

Commit

Permalink
fix(fetcher/checksum): panic when 0 < flen % (block_len * lanes) < bl…
Browse files Browse the repository at this point in the history
…ock_len
  • Loading branch information
PhotonQuantum committed Aug 31, 2023
1 parent 9c20476 commit b20a633
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rsync-fetcher/src/rsync/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,19 @@ fn checksum_payload_(
array_init::array_init(|_| vec![0u8; sum_head.block_len as usize + 4]);

while block_remaining >= simd_impl.lanes() {
if file_remaining < sum_head.block_len as u64 * simd_impl.lanes() as u64 {
// not enough data for simd
break;
}

let mut datas: [&[u8]; md4_simd::simd::MAX_LANES] =
[&[]; md4_simd::simd::MAX_LANES];
for (idx, buf) in bufs[0..simd_impl.lanes()].iter_mut().enumerate() {
// let buf = &mut bufs[idx];

// Sqrt of usize must be in u32 range.
#[allow(clippy::cast_possible_truncation)]
let n1 = min(sum_head.block_len as u64, file_remaining) as usize;
let n1 = sum_head.block_len as usize;

file.read_exact(&mut buf[..n1]).expect("IO error");

Expand Down

0 comments on commit b20a633

Please sign in to comment.