This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] elf: check for rpath emptiness before making a copy of it


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]