From owner-freebsd-hackers Tue Feb 11 23:00:17 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id XAA10021 for hackers-outgoing; Tue, 11 Feb 1997 23:00:17 -0800 (PST) Received: from panda.hilink.com.au (panda.hilink.com.au [203.2.144.5]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id XAA10015 for ; Tue, 11 Feb 1997 23:00:10 -0800 (PST) Received: (from danny@localhost) by panda.hilink.com.au (8.7.6/8.7.3) id SAA07054; Wed, 12 Feb 1997 18:04:59 +1100 (EST) Date: Wed, 12 Feb 1997 18:04:59 +1100 (EST) From: "Daniel O'Callaghan" To: hackers@freebsd.org Subject: strlen() question Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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? Danny size_t strlen(str) const char *str; { register const char *s; for (s = str; *s; ++s); return(s - str); }