From patchwork Tue Sep 22 15:27:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 8822 Received: (qmail 49200 invoked by alias); 22 Sep 2015 15:28: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 49187 invoked by uid 89); 22 Sep 2015 15:28:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_40, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eggs.gnu.org From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: libc-alpha@sourceware.org Cc: guix-devel@gnu.org Subject: [PATCH] Gracefully handle incompatible locale data X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 1 =?utf-8?Q?Vend=C3=A9miaire?= an 224 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x3D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-unknown-linux-gnu Date: Tue, 22 Sep 2015 17:27:55 +0200 Message-ID: <876132lbic.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.10 With libc 2.22 people are starting to realize that libc does not guarantee that it can load locale data built with another libc version, but they learn it the hard way: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_COLLATE) / sizeof (_nl_value_type_LC_COLLATE[0]))' failed. This patch changes such conditions to return EINVAL instead of aborting. WDYT? Thanks, Ludo’. 2015-10-22 Ludovic Courtès * locale/loadlocale.c (_nl_intern_locale_data): Change assertion on CNT to a conditional jump to 'puntdata'. diff --git a/locale/loadlocale.c b/locale/loadlocale.c index fdba6e9..e04e720 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -122,8 +122,9 @@ _nl_intern_locale_data (int category, const void *data, size_t datasize) { #define CATTEST(cat) \ case LC_##cat: \ - assert (cnt < (sizeof (_nl_value_type_LC_##cat) \ - / sizeof (_nl_value_type_LC_##cat[0]))); \ + if (cnt >= (sizeof (_nl_value_type_LC_##cat) \ + / sizeof (_nl_value_type_LC_##cat[0]))) \ + goto puntdata; \ break CATTEST (NUMERIC); CATTEST (TIME);