From patchwork Mon Jun 19 16:18:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 21100 Received: (qmail 81596 invoked by alias); 19 Jun 2017 16:18:53 -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 81578 invoked by uid 89); 19 Jun 2017 16:18:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6666281243 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=fweimer@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6666281243 Date: Mon, 19 Jun 2017 18:18:54 +0200 To: libc-alpha@sourceware.org Subject: [PATCH] _nl_expand_alias: Remove alloca calls User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20170619161854.A214C402AEC0E@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) 2017-06-19 Florian Weimer * intl/localealias.c: Remove alloca support. (read_alias_file): Use asprintf instead of alloca. diff --git a/intl/localealias.c b/intl/localealias.c index 9921aa2..36959df 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -32,30 +32,8 @@ #endif #include -#ifdef __GNUC__ -# undef alloca -# define alloca __builtin_alloca -# define HAVE_ALLOCA 1 -#else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# if defined HAVE_ALLOCA_H || defined _LIBC -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca -char *alloca (); -# endif -# endif -# endif -# endif -#endif - #include +#include #include #include "gettextP.h" @@ -101,15 +79,6 @@ char *alloca (); # define FGETS(buf, n, fp) fgets (buf, n, fp) #endif -/* For those losing systems which don't have `alloca' we have to add - some additional code emulating it. */ -#ifdef HAVE_ALLOCA -# define freea(p) /* nothing */ -#else -# define alloca(n) malloc (n) -# define freea(p) free (p) -#endif - #if defined _LIBC_REENTRANT || defined HAVE_DECL_FGETS_UNLOCKED # undef fgets # define fgets(buf, len, s) fgets_unlocked (buf, len, s) @@ -218,16 +187,9 @@ read_alias_file (const char *fname, int fname_len) FILE *fp; char *full_fname; size_t added; - static const char aliasfile[] = "/locale.alias"; - full_fname = (char *) alloca (fname_len + sizeof aliasfile); -#ifdef HAVE_MEMPCPY - mempcpy (mempcpy (full_fname, fname, fname_len), - aliasfile, sizeof aliasfile); -#else - memcpy (full_fname, fname, fname_len); - memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile); -#endif + if (__asprintf (&full_fname, "%s/locale.alias", fname) < 0) + return 0; #ifdef _LIBC /* Note the file is opened with cancellation in the I/O functions @@ -236,7 +198,7 @@ read_alias_file (const char *fname, int fname_len) #else fp = fopen (relocate (full_fname), "r"); #endif - freea (full_fname); + free (full_fname); if (fp == NULL) return 0;