This is the mail archive of the libc-alpha@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Crash (and crude workaround) for glibc2.x wcsxfrm()


> From: neideck@qkal.sap-ag.de
> Date: Wed, 21 Apr 1999 16:52:21 +0200
> X-Mts: smtp
> 
> 
> Feeding wchar_t strings with characters outside the range 0-255 into
> the wcsxfrm() function when under anu of the 8-bit locales (such as de_DE)
> leads to a crash. This works on other operating systems such as HP/UX and
> Digital Unix (and basically these characters are ignored).

By 'ignored', you mean deleted from the string, or passed through unchanged?

> In order to at least suppress the crashes, I made the following crude fix,
> which avoids feeding anything outside the safe range,
> but probably something better is required (undoubtedly when double-byte
> locales become available).
> 
> *** glibc-2.1/locale/weight.h.old       Wed Apr 21 11:19:03 1999
> --- glibc-2.1/locale/weight.h   Wed Apr 21 11:12:10 1999
> ***************
> *** 83,88 ****
> --- 83,91 ----
>     unsigned int ch = *((USTRING_TYPE *) (*str))++;
>     size_t slot;
> 
> +   if (ch > 255) {
> +     ch = ch & 255;
> +   }
>     if (sizeof (STRING_TYPE) == 1)
>       slot = ch * (collate_nrules + 1);
>     else

Certainly this is wrong.  Probably the right thing to do is pass the
character through unchanged, because wcscoll should treat such
characters like wcscmp does.

-- 
Geoffrey Keating <geoffk@ozemail.com.au>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]