Pointer range checking
#include <rangecheck.h>
int range_validbuf(const void* buf,size_t len);
int range_ptrinbuf(const void* buf,size_t len,const void* ptr);
int range_bufinbuf(const void* buf1,size_t len1,
const void* buf2,size_t len2);
int range_arrayinbuf(const void* buf,size_t len,
const void* arraystart, size_t elements,size_t membersize);
int range_strinbuf(const void* buf,size_t len,const void* string);
int range_str2inbuf(const void* buf,size_t len,const void* string);
int range_str4inbuf(const void* buf,size_t len,const void* string);
rangecheck.h provides several routines for range checking pointers. These routines are meant for code that has to validate the syntax and semantics of buffers coming in from untrusted sources (like a network connection or an input file).
The routines all return 0 on error, or 1 if the pointers were in range.