Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Feb 1997 09:54:52 +0100
From:      j@uriah.heep.sax.de (J Wunsch)
To:        danny@panda.hilink.com.au (Daniel O'Callaghan)
Cc:        hackers@freebsd.org
Subject:   Re: strlen() question
Message-ID:  <Mutt.19970212095452.j@uriah.heep.sax.de>
In-Reply-To: <Pine.BSF.3.91.970212175317.427s-100000@panda.hilink.com.au>; from Daniel O'Callaghan on Feb 12, 1997 18:04:59 %2B1100
References:  <Pine.BSF.3.91.970212175317.427s-100000@panda.hilink.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
As Daniel O'Callaghan wrote:

> 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? 

Why?  The worst that would happen by touching off the end of your
address space is a SIGSEGV.  The problem with str*cpy() touching
beyond the bounds of their arrays is that they can _modify_ the stack
then, but that can't happen with strlen() since it doesn't modify
anything.

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



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