Date: Wed, 12 Feb 1997 20:42:25 +1100 (EST) From: "Daniel O'Callaghan" <danny@panda.hilink.com.au> To: Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de> Cc: hackers@freebsd.org Subject: Re: strlen() question Message-ID: <Pine.BSF.3.91.970212204154.427x-100000@panda.hilink.com.au> In-Reply-To: <Mutt.19970212095452.j@uriah.heep.sax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 12 Feb 1997, J Wunsch wrote: > 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. I was thinking of bounds checking w/o a copy. Danny
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.970212204154.427x-100000>