ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
unarch_io.c File Reference

Flat-memory backing for the shared unarchiver read seam. More...

#include "unarch_io.h"
#include <string.h>
Include dependency graph for unarch_io.c:

Go to the source code of this file.

Functions

size_t unarch_mem_read (void *ctx, uint64_t offset, void *buf, size_t len)
 unarch_read_fn over a flat unarch_mem_t view.

Detailed Description

Flat-memory backing for the shared unarchiver read seam.

Tag
[Ring 4 / Domain] {World: NS}

The one trivial unarch_read_fn implementation everybody shares: a bounds-clamped copy out of a unarch_mem_t view. Reads never touch a byte outside [base, base + len) regardless of the (untrusted) offset and length arguments, so the wrapped-open paths can point it at a decompressed arena without further guarding.

Since
Version 0.1.0

Definition in file unarch_io.c.

Function Documentation

◆ unarch_mem_read()

size_t unarch_mem_read ( void * ctx,
uint64_t offset,
void * buf,
size_t len )
nodiscard

unarch_read_fn over a flat unarch_mem_t view.

Serves [offset, offset + len) clamped to the view's bounds by plain copy. Reads at or past the end return 0 (EOF); a NULL context or view base also returns 0, which every decoder treats as a failed read (fail-closed).

Parameters
[in]ctxThe unarch_mem_t view (may be NULL: reads 0).
[in]offsetAbsolute byte offset within the view.
[out]bufDestination buffer (len writable bytes, non-NULL).
[in]lenBytes requested.
Returns
Bytes actually copied.
Return values
0NULL view / NULL destination, EOF, or a zero-length request.
Precondition
buf holds len writable bytes when len > 0.
The view's base/len describe readable storage.
Postcondition
At most len bytes of buf are written; nothing else changes.
The view itself is never modified (pure read).
Note
Thread-safe: pure read of an immutable view.
See also
unarch_mem_t
Since
Version 0.1.0

Definition at line 24 of file unarch_io.c.

References unarch_mem_t::base, unarch_mem_t::len, and memcpy().

Referenced by internal_open_unwrapped().