mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-14 06:32:33 +00:00
Fix panic in Mp4File::read_from
This commit is contained in:
parent
d13f01d215
commit
9e18616a68
1 changed files with 8 additions and 1 deletions
|
@ -2,7 +2,8 @@ use super::atom_info::{AtomIdent, AtomInfo};
|
||||||
use super::moov::Moov;
|
use super::moov::Moov;
|
||||||
use super::properties::Mp4Properties;
|
use super::properties::Mp4Properties;
|
||||||
use super::Mp4File;
|
use super::Mp4File;
|
||||||
use crate::error::{ErrorKind, LoftyError, Result};
|
use crate::error::{ErrorKind, FileDecodingError, LoftyError, Result};
|
||||||
|
use crate::types::file::FileType;
|
||||||
|
|
||||||
use std::io::{Read, Seek, SeekFrom};
|
use std::io::{Read, Seek, SeekFrom};
|
||||||
|
|
||||||
|
@ -16,6 +17,12 @@ where
|
||||||
return Err(LoftyError::new(ErrorKind::UnknownFormat));
|
return Err(LoftyError::new(ErrorKind::UnknownFormat));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// size + identifier + major brand
|
||||||
|
// There *should* be more, but this is all we need from it
|
||||||
|
if atom.len < 12 {
|
||||||
|
return Err(FileDecodingError::new(FileType::MP4, "\"ftyp\" atom too short").into());
|
||||||
|
}
|
||||||
|
|
||||||
let mut major_brand = vec![0; 4];
|
let mut major_brand = vec![0; 4];
|
||||||
data.read_exact(&mut major_brand)?;
|
data.read_exact(&mut major_brand)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue