Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Feb 1997 10:25:31 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        danny@panda.hilink.com.au (Daniel O'Callaghan)
Cc:        hackers@freebsd.org
Subject:   Re: strlen() question
Message-ID:  <199702121725.KAA00750@phaeton.artisoft.com>
In-Reply-To: <Pine.BSF.3.91.970212175317.427s-100000@panda.hilink.com.au> from "Daniel O'Callaghan" at Feb 12, 97 06:04:59 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> Below is the code for strlen() from libc.  It is extremely simple, and
> fast. Is it really safe to assume that strlen() will never exceed process
> memory bounds before striking a '\0'?  Or should there be a strnlen()
> function in libc for checking the length of suspicious strings? 

[ ... code elided ... ]

Yes.  It is safe.  If the string travels beyond the address space of
the process, the process will fail in a deterministic manner.

PS: You are required to pass only NULL terminated strings to strlen();
    that is the definition of its interface.


					Regards,
					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702121725.KAA00750>