@@ -430,7 +430,7 @@ impl<R: AsyncStreamReader> ResponseDecoder<R> {
430
430
let this = & mut self . 0 ;
431
431
let data = this
432
432
. encoded
433
- . read_bytes ( size)
433
+ . read_bytes_exact ( size)
434
434
. await
435
435
. map_err ( |e| DecodeError :: maybe_leaf_not_found ( e, start_chunk) ) ?;
436
436
let leaf_hash = this. stack . pop ( ) . unwrap ( ) ;
@@ -482,7 +482,7 @@ where
482
482
start_chunk, size, ..
483
483
} => {
484
484
let start = start_chunk. to_bytes ( ) ;
485
- let bytes = data. read_at ( start, size) . await ?;
485
+ let bytes = data. read_exact_at ( start, size) . await ?;
486
486
encoded
487
487
. write_bytes ( bytes)
488
488
. await
@@ -555,7 +555,7 @@ where
555
555
} => {
556
556
let expected = stack. pop ( ) . unwrap ( ) ;
557
557
let start = start_chunk. to_bytes ( ) ;
558
- let bytes = data. read_at ( start, size) . await ?;
558
+ let bytes = data. read_exact_at ( start, size) . await ?;
559
559
let ( actual, to_write) = if !ranges. is_all ( ) {
560
560
// we need to encode just a part of the data
561
561
//
@@ -669,7 +669,7 @@ async fn outboard_impl(
669
669
start_chunk,
670
670
..
671
671
} => {
672
- let buf = data. read_bytes ( size) . await ?;
672
+ let buf = data. read_bytes_exact ( size) . await ?;
673
673
let hash = hash_subtree ( start_chunk. 0 , & buf, is_root) ;
674
674
stack. push ( hash) ;
675
675
}
@@ -722,7 +722,7 @@ async fn outboard_post_order_impl(
722
722
start_chunk,
723
723
..
724
724
} => {
725
- let buf = data. read_bytes ( size) . await ?;
725
+ let buf = data. read_bytes_exact ( size) . await ?;
726
726
let hash = hash_subtree ( start_chunk. 0 , & buf, is_root) ;
727
727
stack. push ( hash) ;
728
728
}
@@ -802,7 +802,9 @@ mod validate {
802
802
if tree. blocks ( ) == 1 {
803
803
// special case for a tree that fits in one block / chunk group
804
804
let mut data = data;
805
- let data = data. read_at ( 0 , tree. size ( ) . try_into ( ) . unwrap ( ) ) . await ?;
805
+ let data = data
806
+ . read_exact_at ( 0 , tree. size ( ) . try_into ( ) . unwrap ( ) )
807
+ . await ?;
806
808
let actual = hash_subtree ( 0 , & data, true ) ;
807
809
if actual == outboard. root ( ) {
808
810
co. yield_ ( Ok ( ChunkNum ( 0 ) ..tree. chunks ( ) ) ) . await ;
@@ -831,7 +833,7 @@ mod validate {
831
833
is_root : bool ,
832
834
) -> io:: Result < ( ) > {
833
835
let len = ( range. end - range. start ) . try_into ( ) . unwrap ( ) ;
834
- let data = self . data . read_at ( range. start , len) . await ?;
836
+ let data = self . data . read_exact_at ( range. start , len) . await ?;
835
837
// is_root is always false because the case of a single chunk group is handled before calling this function
836
838
let actual = hash_subtree ( ChunkNum :: full_chunks ( range. start ) . 0 , & data, is_root) ;
837
839
if & actual == hash {
0 commit comments