Where is strnlen() ?
James Housley
jim at Thehousleys.net
Wed Aug 11 13:06:52 PDT 2004
Thordur Ivar B. wrote:
> While porting software from a friend wich was developed under Linux, I stumbled
> upon an error: src/socket.c:236: warning: implicit declaration of function
> `strnlen'
>
> Now my programming experience is nothing to brag about but I wonder why strnlen
> is not a part of FreeBSD's libc. I think that the use of strlen() insted of
> strnlen() could resault in buffer-overflow risks and my fellows (most of them
> are more experienced in the art of programming say that bounds checking is
> always good.)
>
I see one small, specialiezed use. That is in a structure were a string
for max length doesn't get the terminator, this would prevent reading
throught the rest of the data to find a null somewhere.
Jim
--
/"\ ASCII Ribbon Campaign .
\ / - NO HTML/RTF in e-mail .
X - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
jeh at FreeBSD.org http://www.FreeBSD.org The Power to Serve
jim at TheHousleys.Net http://www.TheHousleys.net
---------------------------------------------------------------------
It's always a long day, 86400 doesn't fit into a short.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3228 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20040811/c0ab8203/smime.bin
More information about the freebsd-hackers
mailing list