range_bufinbuf(3)
π range_bufinbuf β the manual, but make it cute π
okay bestie, we're looking at range_bufinbuf(3) from the Library Functions Manual and honestly? it's a little bouncer for your memory. it checks IDs at the door of a buffer. no cap. let's get into it β¨
πΈ NAME πΈ
range_bufinbuf β range check for buf in buffer π«Ά
β¨ SYNTAX β¨
like, this is literally how you call it, copy-paste energy:
#include <libowfat/rangecheck.h>
int range_bufinbuf(const void* buf1,size_t len1,
const void* buf2,size_t len2);
π¦ DESCRIPTION π¦
so range_bufinbuf checks that the buffer buf2[0..len2-1] lies entirely in buf1[0..len1]. that's it. that's the whole job. it's giving bodyguard, it's giving "is this small thing fully inside this big thing" π
if your buffer is 0-terminated and you don't know the length beforehand, bestie do not use this one β use range_strinbuf, range_str2inbuf or range_str4inbuf instead. they're the girlies built for exactly that situation π
π RETURN VALUE π
here's the vibe check, three ways:
- if one of the buffers is implausible β like
bufisNULL, orbuf+lenhas an integer overflow β it returns0. not me getting overflowed π - if
buf2[0..len2-1]lies before or afterbuf1[0..len1-1], it returns0. outside the club, no entry. - otherwise? it returns
1. β¨ slay. we're in. periodt.
π SEE ALSO π
rangecheck(3)β go read the main character fr fr
that's the whole page, bestie π this was range_bufinbuf(3) from the Library Functions Manual, and if you need me i'll be over here checking that everything stays inside its bounds π§ go forth and range check responsibly, iykyk πβπ
π¦ 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