From owner-freebsd-bugs@FreeBSD.ORG Sat Feb 18 02:20:03 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4881816A420 for ; Sat, 18 Feb 2006 02:20:03 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id BD2AD43D46 for ; Sat, 18 Feb 2006 02:20:02 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k1I2K2fU072649 for ; Sat, 18 Feb 2006 02:20:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k1I2K2x0072648; Sat, 18 Feb 2006 02:20:02 GMT (envelope-from gnats) Resent-Date: Sat, 18 Feb 2006 02:20:02 GMT Resent-Message-Id: <200602180220.k1I2K2x0072648@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, PauAmma Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7AC1A16A420 for ; Sat, 18 Feb 2006 02:13:11 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2692C43D45 for ; Sat, 18 Feb 2006 02:13:11 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k1I2DA5O037727 for ; Sat, 18 Feb 2006 02:13:10 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id k1I2DAA5037726; Sat, 18 Feb 2006 02:13:10 GMT (envelope-from nobody) Message-Id: <200602180213.k1I2DAA5037726@www.freebsd.org> Date: Sat, 18 Feb 2006 02:13:10 GMT From: PauAmma To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: kern/93508: lib/libc/locale/ldpart.c may cause lib/libc/locale/lmessages.c to ignore yesstr if nostr not specified X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Feb 2006 02:20:03 -0000 >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: