From patchwork Tue Sep 19 10:41:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafal Luzynski X-Patchwork-Id: 815417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84714-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="xHpHxI3d"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxKDP0mvcz9s82 for ; Tue, 19 Sep 2017 20:41:24 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:message-id:subject :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=cVY+LCCDH6YfMbNbmGMqLHKWHNK7QIrOUBi9sytUXrRfz2uz1Z2lY 0UH3anBF5Lyv1kl0dQNW3xXbc29CL72EjdDem9yqllmal1u2IbwtzPZFC4PPUXGM dkNkIr+OltrtnIYBdFJLhyORBFAmfvY1b7mietTua1xkK9PCytL34c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:message-id:subject :mime-version:content-type:content-transfer-encoding; s=default; bh=hzhtcTjlJtoez+Z+DfL6lrB37R8=; b=xHpHxI3dDi1JqFHzM8LZmmXJ6A+d bSXU2b0rU54NutuwxYBw7Kjpl3W+hWVCAxex6QQOf4ud0i9iBf0746dlzjRc1Avy q4YtkOHP4OByzsuRo9i3HSyD0RZU2yIWiH6TNCHN0KJY5kbICZvSxCf1xUAQk3JB 3jxp31NC9gZ4lFU= Received: (qmail 80100 invoked by alias); 19 Sep 2017 10:41:15 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 71422 invoked by uid 89); 19 Sep 2017 10:41:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=H*MI:poczta, month, H*x:Mailer, H*UA:Mailer X-HELO: aev204.rev.netart.pl X-Spam-Score: 0 Date: Tue, 19 Sep 2017 12:41:04 +0200 (CEST) From: Rafal Luzynski Reply-To: Rafal Luzynski To: libc-alpha@sourceware.org Message-ID: <291099144.1094665.1505817664806@poczta.nazwa.pl> Subject: [RFC][PATCH v9 1/6] Correct the size of _nl_value_type_LC_... arrays. MIME-Version: 1.0 X-Originating-Client: com.openexchange.ox.gui.dhtml There were several problems with checking the array size in the past, for example BZ#356, caused by incorrectly assuming that every locale token represents one element. In fact, if a token represented a subarray, for example an array of month names or characters category and it appeared at the end of the array the compiler assumed that the array ends just after the first element of the subarray. Workarounds used in the past was to skip some categories while testing, for example LC_CTYPE. Now when we are about to add alternative month names to LC_TIME (BZ#10871) this will fail again. * locale/loadlocale.c: Correct size of _nl_value_type_LC_ arrays. --- ChangeLog | 5 +++++ locale/loadlocale.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 25b05f2..3b8e6c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-09-19 Rafal Luzynski + + * locale/loadlocale.c: Correct size of + _nl_value_type_LC_ arrays. + 2017-09-19 Rajalakshmi Srinivasaraghavan * sysdeps/powerpc/powerpc64/power8/memset.S: Avoid misaligned stores. diff --git a/locale/loadlocale.c b/locale/loadlocale.c index 2bdb39b..cdc3dd4 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -45,7 +45,8 @@ static const size_t _nl_category_num_items[] = #define NO_PAREN(arg, rest...) arg, ##rest #define DEFINE_CATEGORY(category, category_name, items, a) \ -static const enum value_type _nl_value_type_##category[] = { NO_PAREN items }; +static const enum value_type _nl_value_type_##category \ + [_NL_ITEM_INDEX (_NL_NUM_##category)] = { NO_PAREN items }; #define DEFINE_ELEMENT(element, element_name, optstd, type, rest...) \ [_NL_ITEM_INDEX (element)] = type, #include "categories.def"