mirror of
https://codeberg.org/icewind/vbsp.git
synced 2026-06-04 11:04:07 +02:00
validate internal references on parse
This commit is contained in:
parent
d1c9087c37
commit
db738c5eb3
6 changed files with 157 additions and 40 deletions
15
src/error.rs
15
src/error.rs
|
|
@ -22,6 +22,8 @@ pub enum BspError {
|
|||
String(#[from] StringError),
|
||||
#[error("Malformed field found while parsing: {0:#}")]
|
||||
MalformedData(binrw::Error),
|
||||
#[error("bsp file is well-formed but contains invalid data")]
|
||||
Validation(#[from] ValidationError),
|
||||
}
|
||||
|
||||
impl From<binrw::Error> for BspError {
|
||||
|
|
@ -61,3 +63,16 @@ pub enum StringError {
|
|||
#[error("String is not null-terminated")]
|
||||
NotNullTerminated,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ValidationError {
|
||||
#[error(
|
||||
"A {source_} indexes into {target} but the index {index} is out of range of the size {size}"
|
||||
)]
|
||||
ReferenceOutOfRange {
|
||||
source_: &'static str,
|
||||
target: &'static str,
|
||||
index: i64,
|
||||
size: usize,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue