range_arrayinbuf(3)
π range_arrayinbuf(3) π
ok so bestie, welcome to the Library Functions Manual β¨ this is range_arrayinbuf(3) and she is literally the friend who checks your math before you do something unhinged π«Ά
πΈ NAME πΈ
range_arrayinbuf β range check for array in buffer
β¨ SYNTAX β¨
#include <libowfat/rangecheck.h>
int range_arrayinbuf(const void* buf,size_t len,
const void* arraystart,
size_t elements,size_t membersize);
π¦ DESCRIPTION π¦
ok so here's the vibe: range_arrayinbuf checks that the array starting at arraystart, made up of elements members that are membersize each, starts and ends within the buffer buf[0..len-1]. that's it. that's the whole job. and she does it flawlessly π
like, if you're about to go poking at memory and you want a bouncer at the door first? this is your bouncer. no cap π₯
not me about to warn you though: if the array is 0-terminated and you don't know the length beforehand, userange_strinbuf,range_str2inbuforrange_str4inbufinstead π different tool, different job, don't mix them up bestie.
π RETURN VALUE π
so what does she give back? let's go:
- If the buffer is implausible (
bufisNULLorbuf+lenhas an integer overflow), return0. π« - If the array is implausible (
arraystartisNULL,elements*membersizeoverflows, or calculating the byte offset of the last element overflows), return0. π - If the first or last element of the array points before or after the buffer, return
0. π - Otherwise, return
1. β slay!!!
π SEE ALSO π
okay that's the whole page bestie, you ate that π this was range_arrayinbuf(3) from the Library Functions Manual, and yes the title is literally just range_arrayinbuf(3) again at the bottom because manpages are nothing if not consistent π
go be safe with your buffers, ily, bye β¨π¦πΈ
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms