Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site 3comvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!oliveb!3comvax!mikes From: mikes@3comvax.UUCP (Mike Shannon) Newsgroups: net.lang.c Subject: Re: Need strnlen(). Message-ID: <281@3comvax.UUCP> Date: Thu, 14-Nov-85 12:42:03 EST Article-I.D.: 3comvax.281 Posted: Thu Nov 14 12:42:03 1985 Date-Received: Sat, 16-Nov-85 08:30:21 EST References: <767@dcl-cs.UUCP> Organization: 3Com Corp; Mountain View, CA Lines: 16 Stephen Muir in the cited article: > I think that there should be a function called "strnlen" as follows: > > int strnlen (string, size) > char *string; > int size; > > where "size" is the maximum number of bytes in "string". > > The reason is that, if a character array is passed as argument, and it is not > terminated with a null byte, then "strlen" will keep going, possibly hitting > an unallocated piece of memory. Then write one! Geez!! -- Michael Shannon {ihnp4,hplabs}!oliveb!3comvax!mikes