range_arrayinbuf(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_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, use range_strinbuf, range_str2inbuf or range_str4inbuf instead πŸ™ˆ 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 (buf is NULL or buf+len has an integer overflow), return 0. 🚫
  • If the array is implausible (arraystart is NULL, elements*membersize overflows, or calculating the byte offset of the last element overflows), return 0. πŸ’€
  • If the first or last element of the array points before or after the buffer, return 0. 😭
  • Otherwise, return 1. βœ… slay!!!

🌈 SEE ALSO 🌈

rangecheck(3)


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 βœ¨πŸ¦‹πŸŒΈ