Commit e21e9003 authored by Howard Chu's avatar Howard Chu
Browse files

Use LDAP_UTF8_CHARLEN2 to check shortest possible encoding

parent 2d51ad52
...@@ -173,7 +173,7 @@ char * UTF8normalize( ...@@ -173,7 +173,7 @@ char * UTF8normalize(
/* s[i] is non-ascii */ /* s[i] is non-ascii */
/* convert everything up to next ascii to ucs-4 */ /* convert everything up to next ascii to ucs-4 */
while ( i < len ) { while ( i < len ) {
clen = LDAP_UTF8_CHARLEN( s + i ); clen = LDAP_UTF8_CHARLEN2( s + i, clen );
if ( clen == 0 ) { if ( clen == 0 ) {
free( ucs ); free( ucs );
free( out ); free( out );
......
...@@ -471,28 +471,28 @@ UTF8StringValidate( ...@@ -471,28 +471,28 @@ UTF8StringValidate(
for( count = in->bv_len; count > 0; count-=len, u+=len ) { for( count = in->bv_len; count > 0; count-=len, u+=len ) {
/* get the length indicated by the first byte */ /* get the length indicated by the first byte */
len = LDAP_UTF8_CHARLEN( u ); len = LDAP_UTF8_CHARLEN2( u, len );
/* very basic checks */ /* very basic checks */
switch( len ) { switch( len ) {
case 6: case 6:
if( u[5] >= 0xFE ) { if( (u[5] & 0xC0) != 0x80 ) {
return LDAP_INVALID_SYNTAX; return LDAP_INVALID_SYNTAX;
} }
case 5: case 5:
if( u[4] >= 0xFE ) { if( (u[4] & 0xC0) != 0x80 ) {
return LDAP_INVALID_SYNTAX; return LDAP_INVALID_SYNTAX;
} }
case 4: case 4:
if( u[3] >= 0xFE ) { if( (u[3] & 0xC0) != 0x80 ) {
return LDAP_INVALID_SYNTAX; return LDAP_INVALID_SYNTAX;
} }
case 3: case 3:
if( u[2] >= 0xFE ) { if( (u[2] & 0xC0 )!= 0x80 ) {
return LDAP_INVALID_SYNTAX; return LDAP_INVALID_SYNTAX;
} }
case 2: case 2:
if( u[1] >= 0xFE ) { if( (u[1] & 0xC0) != 0x80 ) {
return LDAP_INVALID_SYNTAX; return LDAP_INVALID_SYNTAX;
} }
case 1: case 1:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment