Skip to content

Commit 7c0833e

Browse files
committed
ffi: Assert that the read callback does not return more bytes than requested.
1 parent c6a7594 commit 7c0833e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

mp4parse_capi/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,10 @@ impl Read for Mp4parseIo {
543543
}
544544
let rv = self.read.unwrap()(buf.as_mut_ptr(), buf.len(), self.userdata);
545545
if rv >= 0 {
546+
assert!(
547+
rv as usize <= buf.len(),
548+
"read callback returned more bytes than buffer size"
549+
);
546550
Ok(rv as usize)
547551
} else {
548552
Err(std::io::Error::other("I/O error in Mp4parseIo Read impl"))

0 commit comments

Comments
 (0)