Trait rkyv::validation::ArchiveMemoryContext [−][src]
pub trait ArchiveMemoryContext: Fallible { unsafe fn claim_bytes(
&mut self,
start: *const u8,
len: usize
) -> Result<(), Self::Error>; unsafe fn claim_owned_ptr<T: ArchivePointee + ?Sized>(
&mut self,
ptr: *const T
) -> Result<(), Self::Error>
where
Self: ArchiveBoundsContext,
<T as Pointee>::Metadata: LayoutMetadata<T>, { ... } fn claim_owned_rel_ptr<T: ArchivePointee + ?Sized>(
&mut self,
rel_ptr: &RelPtr<T>
) -> Result<*const T, Self::Error>
where
Self: ArchiveBoundsContext,
<T as Pointee>::Metadata: LayoutMetadata<T>, { ... } }
A context that can validate archive memory.
When implementing archivable containers, an archived type may point to some bytes elsewhere in
the archive using a RelPtr
. Before checking those bytes, they must be claimed in the
context. This prevents infinite-loop attacks by malicious actors by ensuring that each block of
memory has one and only one owner.
Required methods
unsafe fn claim_bytes(
&mut self,
start: *const u8,
len: usize
) -> Result<(), Self::Error>
[src]
&mut self,
start: *const u8,
len: usize
) -> Result<(), Self::Error>
Claims count
bytes located offset
bytes away from base
.
Safety
The caller must guarantee that base
is inside the archive this context was created for.
Provided methods
unsafe fn claim_owned_ptr<T: ArchivePointee + ?Sized>(
&mut self,
ptr: *const T
) -> Result<(), Self::Error> where
Self: ArchiveBoundsContext,
<T as Pointee>::Metadata: LayoutMetadata<T>,
[src]
&mut self,
ptr: *const T
) -> Result<(), Self::Error> where
Self: ArchiveBoundsContext,
<T as Pointee>::Metadata: LayoutMetadata<T>,
Claims the memory at the given location as the given type.
Safety
The caller must guarantee that ptr
is inside the archive this context was created for.
fn claim_owned_rel_ptr<T: ArchivePointee + ?Sized>(
&mut self,
rel_ptr: &RelPtr<T>
) -> Result<*const T, Self::Error> where
Self: ArchiveBoundsContext,
<T as Pointee>::Metadata: LayoutMetadata<T>,
[src]
&mut self,
rel_ptr: &RelPtr<T>
) -> Result<*const T, Self::Error> where
Self: ArchiveBoundsContext,
<T as Pointee>::Metadata: LayoutMetadata<T>,
Claims the memory referenced by the given relative pointer.
Implementors
impl<C: ArchiveBoundsContext> ArchiveMemoryContext for ArchiveValidator<C>
[src]
impl<C: ArchiveBoundsContext> ArchiveMemoryContext for ArchiveValidator<C>
[src]impl<C: ArchiveMemoryContext> ArchiveMemoryContext for SharedArchiveValidator<C>
[src]
impl<C: ArchiveMemoryContext> ArchiveMemoryContext for SharedArchiveValidator<C>
[src]