[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
t61.c (ITS#2388)
Full_Name: Peter Gutekunst
Version: 2.1.13
OS: Windows2000
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (217.225.11.245)
When we worked with openldap-2.1.13-module t61.c we had a problem with the
following routine when we tried to transform strings containing letters with
diaeresesis:
/* Transform a T.61 string to UTF-8.
*/
int ldap_t61s_to_utf8s( struct berval *src, struct berval *dst )
{
unsigned char *c;
char *d;
int i, wlen = 0;
/* Just count the length of the UTF-8 result first */
for (i=0,c=(unsigned char *)src->bv_val; i < src->bv_len; c++,i++) {
/* Invalid T.61 characters? */
if (!t61_tab[*c])
return LDAP_INVALID_SYNTAX;
if (*c & 0xf0 == 0xc0) {
/*
* PROBLEM!! the comparison-operator(==) was stronger then the bitwise and(&) so
* the if-block was never entered. By bracketing as follows we got better
results.
* if ((*c & 0xf0) == 0xc0) {
*/
int j = *c & 0x0f;
/* If this is the end of the string, or if the base
* character is just a space, treat this as a regular
* spacing character.
*/
if ((!c[1] || c[1] == 0x20) && accents[j]) {
wlen += ldap_x_wc_to_utf8(NULL, accents[j], 0);
} else if (cx_tab[j] && cx_tab[j][c[1]>>5] &&
/* We have a composite mapping for this pair */
(*cx_tab[j][c[1]>>5])[c[1]&0x1f]) {
wlen += ldap_x_wc_to_utf8( NULL,(*cx_tab[j][c[1]>>5])[c[1]&0x1f], 0);
} else {
/* No mapping, just swap it around so the base
* character comes first.
*/
wlen += ldap_x_wc_to_utf8(NULL, c[1], 0);
wlen += ldap_x_wc_to_utf8(NULL, t61_tab[*c], 0);
}
c++; i++;
continue;
} else {
wlen += ldap_x_wc_to_utf8(NULL, t61_tab[*c], 0);
}
}
/* Now transform the string */
dst->bv_len = wlen;
dst->bv_val = LDAP_MALLOC( wlen+1 );
d = dst->bv_val;
if (!d)
return LDAP_NO_MEMORY;
for (i=0,c=(unsigned char *)src->bv_val; i < src->bv_len; c++,i++) {
if (*c & 0xf0 == 0xc0) {
/*
* PROBLEM!! the comparison-operator(==) was stronger then the bitwise
and(&) so
* the if-block was never entered.
*/
int j = *c & 0x0f;
.......
}