Skip to content

Commit

Permalink
Merge pull request #38 from DLR-FT/dev/invalid-parm
Browse files Browse the repository at this point in the history
fix(a653rs)!: fix errors on write verification
  • Loading branch information
sevenautumns authored Feb 23, 2024
2 parents 69389ab + a4fe4a7 commit 4172e20
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/apex/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ pub mod abstraction {
InvalidMode,
/// time-out tied up with request has expired
TimedOut,
/// buffer got zero length or is to long
/// buffer is too large
WriteError,
/// buffer is to small
/// buffer is too small
ReadError,
}

Expand Down Expand Up @@ -219,12 +219,14 @@ pub mod abstraction {
}

fn validate_write(&self, size: MessageSize) -> Result<&Self, Error> {
// This is what the hypervisor would return, but we can detect the error early.
if usize::try_from(size)
.map(|ss| self.len() > ss)
.unwrap_or(false)
|| self.is_empty()
{
return Err(Error::WriteError);
return Err(Error::InvalidConfig);
} else if self.is_empty() {
return Err(Error::InvalidParam);
}
Ok(self)
}
Expand Down

0 comments on commit 4172e20

Please sign in to comment.