hi guys, what about a new function called strnlen str*n*len which will return the length of a string with a given maximum to avoid problems with strings not zero terminated.
i suggest we put this in a single .c file near strlcpy.c /* {{{ php_strnlen * get length of string if buffer if less than buffer size or buffer size */ static size_t php_strnlen( char* str, size_t maxlen) { size_t len = 0; if ( str && maxlen && *str) { do { len++; } while ( --maxlen && *(++str)); } return len; } /* }}} */ I already had a small discussion with Andy >Andi: There aren't supposed to be strings which aren't zero terminated and if there are it should be fixed (or am I missing something?). Of cause not but currently i am working on ext/exif and i cannot assume that a file is correct. So when i scan a buffer whose length i now i cannot exceed it's length when searching for NUL to determine its string length. I must stop searching for NUL if buffer end is reached. Also there are situations in which you have a string with now NUL from outside PHP (which was one of the many errors in exif.c) .... So i think i am not the only one who use this...(or shoul i say must use this for savety reasons?) marcus -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php