Re: Buffer overflow in "lpr"

Wietse Venema (wietse@WZV.WIN.TUE.NL)
Thu, 17 Jul 1997 12:39:08 -0400

der Mouse wrote:
> > Try this on for size: strlcat(), [...]
>
> What _I_ most often want but don't have is strnlen():
>
> size_t strnlen(const char *str, size_t maxlen)
>
> Just like strlen(str), except that if no NUL is found in the
> first maxlen bytes, returns maxlen without attempting to access
> any further bytes.

On ANSI-C compliant systems, memchr(str, 0, len) does almost the
same (difference: the result is a pointer instead of a length).

Wietse