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]

Claims count bytes located offset bytes away from base.

Safety

base must be inside the archive this context was created for.

Loading content...

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]

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]

Claims the memory referenced by the given relative pointer.

Loading content...

Implementors

impl<C: ArchiveBoundsContext> ArchiveMemoryContext for ArchiveValidator<C>[src]

impl<C: ArchiveMemoryContext> ArchiveMemoryContext for SharedArchiveValidator<C>[src]

Loading content...