pub struct NdrDecoder<'a> { /* private fields */ }Expand description
Deserializer over a stub buffer.
Implementations§
Source§impl<'a> NdrDecoder<'a>
impl<'a> NdrDecoder<'a>
pub fn new(buf: &'a [u8]) -> Self
pub fn align(&mut self, a: usize)
pub fn u8(&mut self) -> Result<u8>
pub fn u16(&mut self) -> Result<u16>
pub fn u32(&mut self) -> Result<u32>
pub fn u64(&mut self) -> Result<u64>
pub fn uuid(&mut self) -> Result<[u8; 16]>
Sourcepub fn conformant_varying_wstr(&mut self) -> Result<String>
pub fn conformant_varying_wstr(&mut self) -> Result<String>
Read a conformant+varying wide string; returns it without the trailing NUL.
§Bounded allocation
The actual_count field is attacker-controlled (comes off the wire).
A naive Vec::with_capacity(actual) here would let a remote peer
trigger a multi-GB allocation before we notice the buffer is short.
This decoder preflights the size against the remaining buffer: if
actual * 2 bytes aren’t physically available, we return
NdrError::Underrun before touching the allocator.
Sourcepub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8]>
pub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8]>
Read n raw bytes with no alignment (e.g. a fixed context handle or tower blob).
pub fn remaining(&self) -> usize
pub fn position(&self) -> usize
Auto Trait Implementations§
impl<'a> Freeze for NdrDecoder<'a>
impl<'a> RefUnwindSafe for NdrDecoder<'a>
impl<'a> Send for NdrDecoder<'a>
impl<'a> Sync for NdrDecoder<'a>
impl<'a> Unpin for NdrDecoder<'a>
impl<'a> UnsafeUnpin for NdrDecoder<'a>
impl<'a> UnwindSafe for NdrDecoder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more