[PATCH v2] locale: don't crash if locale-archive contains all zeros
Andreas Schwab
schwab@linux-m68k.org
Tue Dec 3 11:21:00 GMT 2013
Aurelien Jarno <aurelien@aurel32.net> writes:
> diff --git a/locale/loadarchive.c b/locale/loadarchive.c
> index 70136dc..f723780 100644
> --- a/locale/loadarchive.c
> +++ b/locale/loadarchive.c
> @@ -274,6 +274,10 @@ _nl_load_locale_from_archive (int category, const char **namep)
> namehashtab = (struct namehashent *) ((char *) head
> + head->namehash_offset);
>
> + /* Avoid division by 0 if the file is corrupted. */
> + if (__glibc_unlikely (head->namehash_size == 0))
> + goto close_and_out;
> +
> idx = hval % head->namehash_size;
> incr = 1 + hval % (head->namehash_size - 2);
That won't help for head->namehash_size == 2, or any other corruptions.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
More information about the Libc-alpha
mailing list