kern/93508: lib/libc/locale/ldpart.c may cause lib/libc/locale/lmessages.c to ignore yesstr if nostr not specified

PauAmma pauamma at gundo.com
Fri Feb 17 18:20:03 PST 2006


>Number:         93508
>Category:       kern
>Synopsis:       lib/libc/locale/ldpart.c may cause lib/libc/locale/lmessages.c to ignore yesstr if nostr not specified
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Feb 18 02:20:02 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     PauAmma
>Release:        4.11 (likely present in 5.x and 6.x too)
>Organization:
Ecdysiasts United For Overdressing
>Environment:
N/A
>Description:
>From lib/libc/locale/lmessages.c,v 1.14, function __messages_load_locale:

        if (ret == _LDP_LOADED) {
                if (_messages_locale.yesstr == NULL)
                        _messages_locale.yesstr = empty;
                if (_messages_locale.nostr == NULL)
                        _messages_locale.nostr = empty;
        }

This implies that yesstr and nostr can be left unspecified independently. However, lib/libc/locale/ldpart.c,v 1.15; function __part_load_locale has the following:

        num_lines = split_lines(p, plim);
        if (num_lines >= locale_buf_size_max)
                num_lines = locale_buf_size_max;
        else if (num_lines >= locale_buf_size_min)
                num_lines = locale_buf_size_min;
        else {
                errno = EFTYPE;
                goto bad_lbuf;
        }

Most callers of __part_load_locale pass the same value in locale_buf_size_max and locale_buf_size_min, but __messages_load_locale passes 4 and 2, respectively (as far as I can tell from reading the source). This means that if some, but not all, of the optional lines are present in the locale file, the lines that are present will be ignored (or reset to their default value) by the following code (later in __part_load_locale):

        for (i = num_lines; i < locale_buf_size_max; i++)
                dst_localebuf[i] = NULL;

This is inconsistent with __messages_load_locale, which allows yesstr (line 3, counting from 1) to be specified even if nostr isn't.
>How-To-Repeat:
Use locale ro_RO.ISO8859-2 or ro_RO.UTF-8. (For some reason, LC_MESSAGES has 3 lines for those locales.)
>Fix:
In __part_load_locale, change:

        else if (num_lines >= locale_buf_size_min)
                num_lines = locale_buf_size_min;
        else {
                errno = EFTYPE;
                goto bad_lbuf;
        }

to:

         else if (num_lines <= locale_buf_size_min) {
                errno = EFTYPE;
                goto bad_lbuf;
        }

Note: not tested at all.
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list