Re: cvs: php4 /ext/standard string.c /ext/standard/tests/strings wordwrap.phpt

From: Date: Sat, 05 Jan 2002 18:03:28 +0000
Subject: Re: cvs: php4 /ext/standard string.c /ext/standard/tests/strings wordwrap.phpt
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-75962@lists.php.net to get a copy of this message
Andi Gutmans <andi@zend.com> wrote: > If you need to use something like strncat()/strncpy() you should use > strlcpy()/strlcat(). We changed to these functions a couple of years ago. in the case of wordwrap(), it is only copying part of the source string, so strlcat() wouldn't do the job. i figured it'd be more confusing to mix calls to strncat() and strlcat() in the same function than to just use strncat() consistently. the destination buffer is verifiably large enough to handle all of the strncat() calls. (now, i did think of keeping track of the current position in the destination buffer and using memcpy(), but it seemed like overkill. the size of the new buffer could be calculated more intelligently, too, by taking into account the requested line length and size of the original text to figure out the maximum number of breaks that will be inserted. but that's all optimization. i was mainly out to fix the segfault.) jim

« previous php.dev (#75962) next »