Start: double-bounded string mutation functions.

These bound `dest` and `src`, so will assure no OOB writes *and* no OOB reads.

Functions prototyped only, (not yet implemented.)

Fortune for naka's current commit: Middle blessing − 中吉
display_format_safety
Avril 3 years ago
parent e9ccf5e2f2
commit eee5203ba9
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -21,6 +21,18 @@ static usize strncpy_n(char*pOUT dest, const char* restrict src, usize n)
return i;
}
// Will not write past `dn` bytes of `dest`, will not read past `sn` bytes of `src`. Otherwise, same as `strncpy_n()`.
static usize s_strncpy_n(usize sn, usize dn; char dest[static pOUT dn], usize dn, const char src[static restrict sn], usize sn)
{
TODO("double-bounded strncpy");
}
// Will not write past `dn` bytes of `dest`, will not read past `sn` bytes of `src`. Otherwise, same as `strncat_n()`.
static usize s_strncat_n(usize sn, usize dn; char dest[static pOUT dn], usize dn, const char src[static restrict sn], usize sn)
{
TODO("double-bounded strncat");
}
// Returns number of bytes written to (dest+strlen(dest)). Otherwise same as `strncat()`.
static inline usize strncat_n(char*pOUT dest, const char* restrict src, usize n)
{

Loading…
Cancel
Save