This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] elf: check for rpath emptiness before making a copy of it
- From: Aurelien Jarno <aurelien at aurel32 dot net>
- To: libc-alpha at sourceware dot org
- Date: Sun, 31 Dec 2017 17:36:07 +0100
- Subject: Re: [PATCH] elf: check for rpath emptiness before making a copy of it
- Authentication-results: sourceware.org; auth=none
- References: <20171227230220.GC11902@altlinux.org>
On 2017-12-28 02:02, Dmitry V. Levin wrote:
> * 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)
That looks good to me.
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://www.aurel32.net