[PATCH] ld.so: Check for new cache format first and enhance corruption check

Andreas Schwab schwab@linux-m68k.org
Tue May 19 14:45:10 GMT 2020


On Mai 19 2020, Florian Weimer via Libc-alpha wrote:

> Now that ldconfig defaults to the new format (only), check for it
> first.  Also apply the corruption check added in commit 2954daf00bb4d
> ("Add more checks for valid ld.so.cache file (bug 18093)") to the
> new-format-only case.

Ok.

> diff --git a/elf/dl-cache.c b/elf/dl-cache.c
> index 3eedd9afcf..14691d3d2b 100644
> --- a/elf/dl-cache.c
> +++ b/elf/dl-cache.c
> @@ -199,11 +199,21 @@ _dl_load_cache_lookup (const char *name)
>  					       PROT_READ);
>  
>        /* We can handle three different cache file formats here:
> +	 - only the new format
>  	 - the old libc5/glibc2.0/2.1 format
>  	 - the old format with the new format in it
> -	 - only the new format
>  	 The following checks if the cache contains any of these formats.  */
> -      if (file != MAP_FAILED && cachesize > sizeof *cache
> +      if (file != MAP_FAILED && cachesize > sizeof *cache_new
> +	       && memcmp (file, CACHEMAGIC_VERSION_NEW,
> +			  sizeof CACHEMAGIC_VERSION_NEW - 1) == 0

Wrong indent.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


More information about the Libc-alpha mailing list