From patchwork Wed Dec 27 23:02:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dmitry V. Levin" X-Patchwork-Id: 25133 Received: (qmail 29043 invoked by alias); 27 Dec 2017 23:02:24 -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 29032 invoked by uid 89); 27 Dec 2017 23:02:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: vmicros1.altlinux.org Date: Thu, 28 Dec 2017 02:02:21 +0300 From: "Dmitry V. Levin" To: libc-alpha@sourceware.org Subject: [PATCH] elf: check for rpath emptiness before making a copy of it Message-ID: <20171227230220.GC11902@altlinux.org> Mail-Followup-To: libc-alpha@sourceware.org MIME-Version: 1.0 Content-Disposition: inline * elf/dl-load.c (decompose_rpath): Check for rpath emptiness before making a copy of it. --- ChangeLog | 3 +++ elf/dl-load.c | 18 ++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index ae86f0b..f3ff49b 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -490,7 +490,6 @@ decompose_rpath (struct r_search_path_struct *sps, { /* Make a copy we can work with. */ const char *where = l->l_name; - char *copy; char *cp; struct r_search_path_elem **result; size_t nelems; @@ -529,22 +528,21 @@ decompose_rpath (struct r_search_path_struct *sps, while (*inhp != '\0'); } + /* Ignore empty rpaths. */ + if (*rpath == '\0') + { + sps->dirs = (struct r_search_path_elem **) -1; + return false; + } + /* Make a writable copy. */ - copy = __strdup (rpath); + char *copy = __strdup (rpath); if (copy == NULL) { errstring = N_("cannot create RUNPATH/RPATH copy"); goto signal_error; } - /* Ignore empty rpaths. */ - if (*copy == 0) - { - free (copy); - sps->dirs = (struct r_search_path_elem **) -1; - return false; - } - /* Count the number of necessary elements in the result array. */ nelems = 0; for (cp = copy; *cp != '\0'; ++cp)