range_str4inbuf(3) range check for string in buffer


#include <rangecheck.h>

int range_str4inbuf(const void* buf,size_t len,const void* string);


range_str4inbuf checks that the zero terminated UTF-32-string starting at string starts and ends within the buffer buf[0..len-1].

If the string is not 0-terminated but the length is known beforehand, use range_arrayinbuf instead.


If the buffer is implausible (buf is NULL or buf+len has an integer overflow), return 0.

If string points before or after the buffer, return 0.

If there is no zero terminator within the buffer, return 0.

Otherwise, return 1.