[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#5720) ldap_str2charray calls ldap_utf8_strchr incorrectly

h.b.furuseth@usit.uio.no wrote:
> quanah@OpenLDAP.org writes:
>> utf-8.c:char * (ldap_utf8_strchr)( const char *str, const char *chr )
>> I.e., string, character, as normal libc functions.
>> However, at line 125 in charray.c, it is called as:
>>                  if ( ldap_utf8_strchr( brkstr, s ) != NULL ) {
>> This order appears to be incorrect.

> No.  That code counts the number of delimiters characters in the
> string being split.  Since brkstr can contain several characters,
> the loop checks each "utf-8 character" in str against brkstr.

The code was certainly broken, regardless. If the input string uses any UTF8 
characters beyond 0x7f then the simple increment of "s++" would yield invalid 
characters for most of the iterations of the loop.
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/