range_bufinbuf(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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 buf is NULL, or buf+len has an integer overflow β€” it returns 0. not me getting overflowed 😭
  • if buf2[0..len2-1] lies before or after buf1[0..len1-1], it returns 0. outside the club, no entry.
  • otherwise? it returns 1. ✨ slay. we're in. periodt.

πŸ‘‘ SEE ALSO πŸ‘‘


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 πŸŒˆβ­πŸ’œ