Skip to content

Commit

Permalink
Add check
Browse files Browse the repository at this point in the history
  • Loading branch information
wcampbell0x2a committed Aug 3, 2023
1 parent 4768d51 commit 27f1983
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ impl<R: Read> Container<R> {
#[inline]
pub fn read_bytes(&mut self, amt: usize, buf: &mut [u8]) -> Result<ContainerRet, DekuError> {
if self.leftover.is_empty() {
if buf.len() < amt {
return Err(DekuError::Incomplete(NeedSize::new(amt * 8)));
}
if let Err(e) = self.inner.read_exact(&mut buf[..amt]) {
if e.kind() == io::ErrorKind::UnexpectedEof {
return Err(DekuError::Incomplete(NeedSize::new(amt * 8)));
Expand Down

0 comments on commit 27f1983

Please sign in to comment.