diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2013-12-03 11:16:16 +0100 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2013-12-03 11:16:16 +0100 |
commit | 18d1425127e5712dda888bb280d5d1a038a45c7f (patch) | |
tree | 1633427d7b3f7ea9abac01473faa517788839268 | |
parent | 520d437b9455560d099fe6bd9664be1f9f76868b (diff) | |
download | glibc-18d1425127e5712dda888bb280d5d1a038a45c7f.tar.gz glibc-18d1425127e5712dda888bb280d5d1a038a45c7f.tar.xz glibc-18d1425127e5712dda888bb280d5d1a038a45c7f.zip |
locale: don't crash if locale-archive contains all zeros
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.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | locale/loadarchive.c | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index 182051a727..aec3cb2651 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-12-03 Aurelien Jarno <aurelien@aurel32.net> + + * locale/loadarchive.c (_nl_load_locale_from_archive): Avoid + division by 0. + 2013-12-03 Siddhesh Poyarekar <siddhesh@redhat.com> [BZ #16195] diff --git a/locale/loadarchive.c b/locale/loadarchive.c index 70136dcf95..f723780ce1 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); |