]> git.sur5r.net Git - openldap/commitdiff
Use LDAP_UTF8_CHARLEN2 to check shortest possible encoding
authorHoward Chu <hyc@openldap.org>
Tue, 15 Jan 2002 08:27:19 +0000 (08:27 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 15 Jan 2002 08:27:19 +0000 (08:27 +0000)
libraries/liblunicode/ucstr.c
servers/slapd/schema_init.c

index 1c0b0b80099dc973d21c574615db1c76f2c52017..1a849387399679873f3b2026d444228cd40dfe02 100644 (file)
@@ -173,7 +173,7 @@ char * UTF8normalize(
                /* s[i] is non-ascii */
                /* convert everything up to next ascii to ucs-4 */
                while ( i < len ) {
-                       clen = LDAP_UTF8_CHARLEN( s + i );
+                       clen = LDAP_UTF8_CHARLEN2( s + i, clen );
                        if ( clen == 0 ) {
                                free( ucs );
                                free( out );
index bf1484603d204a32da774ede64107787ddd365ea..85992cfd0a884570b5df0f602246c9a53d590335 100644 (file)
@@ -471,28 +471,28 @@ UTF8StringValidate(
 
        for( count = in->bv_len; count > 0; count-=len, u+=len ) {
                /* get the length indicated by the first byte */
-               len = LDAP_UTF8_CHARLEN( u );
+               len = LDAP_UTF8_CHARLEN2( u, len );
 
                /* very basic checks */
                switch( len ) {
                        case 6:
-                               if( u[5] >= 0xFE ) {
+                               if( (u[5] & 0xC0) != 0x80 ) {
                                        return LDAP_INVALID_SYNTAX;
                                }
                        case 5:
-                               if( u[4] >= 0xFE ) {
+                               if( (u[4] & 0xC0) != 0x80 ) {
                                        return LDAP_INVALID_SYNTAX;
                                }
                        case 4:
-                               if( u[3] >= 0xFE ) {
+                               if( (u[3] & 0xC0) != 0x80 ) {
                                        return LDAP_INVALID_SYNTAX;
                                }
                        case 3:
-                               if( u[2] >= 0xFE ) {
+                               if( (u[2] & 0xC0 )!= 0x80 ) {
                                        return LDAP_INVALID_SYNTAX;
                                }
                        case 2:
-                               if( u[1] >= 0xFE ) {
+                               if( (u[1] & 0xC0) != 0x80 ) {
                                        return LDAP_INVALID_SYNTAX;
                                }
                        case 1: