This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] locale: don't crash if locale-archive contains all zeros
- From: Aurelien Jarno <aurelien at aurel32 dot net>
- To: Carlos O'Donell <carlos at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 3 Dec 2013 11:17:45 +0100
- Subject: Re: [PATCH v2] locale: don't crash if locale-archive contains all zeros
- Authentication-results: sourceware.org; auth=none
- References: <1385897760-24820-1-git-send-email-aurelien at aurel32 dot net> <529CB9E3 dot 5080406 at redhat dot com>
On Mon, Dec 02, 2013 at 11:48:35AM -0500, Carlos O'Donell wrote:
> On 12/01/2013 06:36 AM, Aurelien Jarno wrote:
> > In case of power failure followed by filesystem issues locale-archive
> > can end-up containing all zeros. In that case all calls to setlocale()
> > generate a SIGFPE. This renders a system with a default non-C locale
> > unbootable.
> >
> > Avoid this by ignoring the locale instead of generating a SIGFPE.
> > ---
> > locale/loadarchive.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > 2013-12-01 Aurelien Jarno <aurelien@aurel32.net>
> >
> > * locale/loadarchive.c (_nl_load_locale_from_archive): Avoid
> > division by 0.
> >
> > 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);
> >
> >
>
> Looks OK to me as long as you did the same testing as last time,
> and no regressions in the testsuite.
Yes, I did the same testing, and I have seen no regression in the
testsuite. I have therefore committed my changes.
> Please remember to state your testing results along with your post.
>
Ok.
Cheers,
Aurelien
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net