From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5BA7C139084 for ; Sat, 25 Nov 2017 18:33:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ADA46E0D34; Sat, 25 Nov 2017 18:33:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 60751E0D2E for ; Sat, 25 Nov 2017 18:33:44 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 13BBC33BEC7 for ; Sat, 25 Nov 2017 18:33:43 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id CABD1A75A for ; Sat, 25 Nov 2017 18:33:41 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1511624449.e24576aae416fbe8c86b4bd528ba86dd79c5a062.grobian@gentoo> Subject: [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/files/ X-VCS-Repository: repo/proj/prefix X-VCS-Files: sys-devel/binutils-config/files/ldwrapper.c X-VCS-Directories: sys-devel/binutils-config/files/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: e24576aae416fbe8c86b4bd528ba86dd79c5a062 X-VCS-Branch: master Date: Sat, 25 Nov 2017 18:33:41 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: a21e35da-cd84-44c7-b693-9934314e4e8f X-Archives-Hash: 9ba84aa7032682c31fa7bc916b2000f3 commit: e24576aae416fbe8c86b4bd528ba86dd79c5a062 Author: Fabian Groffen gentoo org> AuthorDate: Sat Nov 25 15:40:49 2017 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sat Nov 25 15:40:49 2017 +0000 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=e24576aa sys-devel/binutils-config: avoid malloc for fixed-size bugger Package-Manager: Portage-2.3.13-prefix, Repoman-2.3.4 sys-devel/binutils-config/files/ldwrapper.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c index c971ef4d9d..fda6e9b603 100644 --- a/sys-devel/binutils-config/files/ldwrapper.c +++ b/sys-devel/binutils-config/files/ldwrapper.c @@ -1,7 +1,8 @@ /* - * Copyright 1999-2013 Gentoo Foundation + * Copyright 1999-2017 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 * Authors: Fabian Groffen + * Michael Haubenwallner */ #include @@ -19,6 +20,7 @@ * * On Darwin it adds -search_path_first to make sure the given paths are * searched before the default search path. + * On AIX it ensures -bsvr4 is the last argument. * The wrapper will inject -L entries for: * - EPREFIX/usr/CHOST/lib/gcc (when gcc) * - EPREFIX/usr/CHOST/lib (when binutils) @@ -44,7 +46,7 @@ find_real_ld(char **ld, char verbose, char *wrapper) char *ldoveride; char *path; #define ESIZ 1024 - char *e; + char e[ESIZ]; struct stat lde; /* we may not succeed finding the linker */ @@ -63,12 +65,6 @@ find_real_ld(char **ld, char verbose, char *wrapper) fprintf(stdout, "%s: BINUTILS_CONFIG_LD not found in environment\n", wrapper); - if ((e = malloc(sizeof(char) * ESIZ)) == NULL) { - fprintf(stderr, "%s: out of memory allocating string for path to ld\n", - wrapper); - exit(1); - } - /* find ld in PATH, allowing easy PATH overrides */ path = getenv("PATH"); while (path > (char*)1 && *path != '\0') { @@ -92,7 +88,7 @@ find_real_ld(char **ld, char verbose, char *wrapper) /* parse EPREFIX/etc/env.d/binutils/config-CHOST to get CURRENT, then * consider $EPREFIX/usr/CHOST/binutils-bin/CURRENT where we should * be able to find ld */ - *e = '\0'; + e[0] = '\0'; if ((f = fopen(EPREFIX "/etc/env.d/binutils/config-" CHOST, "r")) != NULL) { char p[ESIZ]; while (fgets(p, ESIZ, f) != NULL) { @@ -121,7 +117,7 @@ find_real_ld(char **ld, char verbose, char *wrapper) /* last try, call binutils-config to tell us what the linker is * supposed to be */ - *e = '\0'; + e[0] = '\0'; if ((f = popen("binutils-config -c", "r")) != NULL) { char p[ESIZ]; char *q;