bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Critical : setlocale changes behavior in libc2.2


From: Jody Goldberg
Subject: Critical : setlocale changes behavior in libc2.2
Date: Tue, 28 Nov 2000 21:51:17 -0500
User-agent: Mutt/1.2.5i

It seems as if setlocale (category, locale_str) no longer copies
locale_str.  This breaks the common use case that is recommended in
the info pages.

A common idiom when temporarily changing the locale is to write
something like :

    tmp = strdup (setlocale (LC_NUMERIC, NULL));
    setlocale (LC_NUMERIC, "C");
    <operation>
    setlocale (LC_NUMERIC, tmp);
    free (tmp);

The strdup is necessary because the locale appears to have been
stored in a static buffer on older systems, and changing the locale
invalidated the previous setting.  The new copy semantics of
setlocale break this completely.  Either the caller leaks (and does
not free tmp), or we access freed memory the next time someone
queries the setting.

This usage is common in
    : gnumeric
    : gnome-libs
    : glib
and is recommended in the glibc info page.

There are enough sanity checks in the code that the only result is
to reset the locale to 'C'.  I believe this needs to be patched
quickly before 2.2 gets into wider circulation.  Gnumeric is already
receiving bug reports resulting from this.  If I can be of any
assistance please contact me.

Thanks
    Jody



reply via email to

[Prev in Thread] Current Thread [Next in Thread]