Closed kennytm closed 7 years ago
The InvalidData is thrown from this line https://github.com/ebarnard/rust-plist/blob/1df5db005ea9959c4e19107997f446dc17095be4/src/binary/reader.rs#L73:
fn allocate_vec<T>(&self, len: u64) -> Result<Vec<T>> {
if self.can_allocate::<T>(len) {
Ok(Vec::with_capacity(len as usize))
} else {
Err(Error::InvalidData)
}
}
here, len == 1
, T == u64
and self.max_allocation == 2
, thus 1*8 > 2 and can_allocate()
returns false.
Probably the 6-byte padding in the trailing should be counted towards the max_allocation
.
Relevant stack trace:
0: <plist::binary::reader::EventReader<R>>::allocate_vec
1: <plist::binary::reader::EventReader<R>>::read_ints
2: <plist::binary::reader::EventReader<R>>::read_trailer
3: <plist::binary::reader::EventReader<R>>::read_next
4: <plist::binary::reader::EventReader<R> as core::iter::iterator::Iterator>::next
Thanks for the report. Fixed in 0.1.3.
Test case: (file is taken from iOS 10.3 file system image)
Expected: The program finishes with no error. Actual: The program panics with:
Please compare with Python 3's
plistlib
:Tested with commit 1df5db00 (current master)