From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: [PATCH] Gracefully handle incompatible locale data Date: Tue, 22 Sep 2015 17:27:55 +0200 Message-ID: <876132lbic.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org To: libc-alpha@sourceware.org Cc: guix-devel@gnu.org List-Id: guix-devel.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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_v= alue_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=E2=80=99. 2015-10-22 Ludovic Court=C3=A8s * locale/loadlocale.c (_nl_intern_locale_data): Change assertion on CNT to a conditional jump to 'puntdata'. --=-=-= Content-Type: text/x-patch Content-Disposition: inline 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); --=-=-=--