Red Hat Bugzilla – Bug 1470124
_nl_load_locale_from_archive SIGFPE divide by zero
Last modified: 2017-11-19 21:57:53 EST
Description of problem: _nl_load_locale_from_archive defends incompletely against dividing by zero.
Version-Release number of selected component (if applicable):
How reproducible: every time (if particular corruption in locale archive)
Steps to Reproduce:
1. Inspect code for _nl_load_locale_from_archive()
Actual results: In glibc-2.24-59-g86ac4a7/locale/loadarchive.c near lines 277 through 282:
/* Avoid division by 0 if the file is corrupted. */
if (__glibc_unlikely (head->namehash_size == 0))
idx = hval % head->namehash_size;
incr = 1 + hval % (head->namehash_size - 2);
The check defends against dividing by zero in the first modulo operation ('%') but not the second (on the next line). The check should be expanded to "head->namehash_size <= 2".
The declaration in locarchive.h is
It seems to me that some heuristic such as (namehash_size >= (0xful << 28)) also is appropriate, to detect extremely unlikely large values [in this case 4,026,531,840 and larger].
Expected results: Correct defense against dividing by zero in all modulo operations ('%' operator).
Out of curiosity, how did you encounter this bug?
(In reply to Florian Weimer from comment #1)
> Out of curiosity, how did you encounter this bug?
A side effect of investigating https://bugzilla.redhat.com/show_bug.cgi?id=1468778
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora 'version'
Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.
Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.
Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.
The problem persists in
which is the source for