Description of problem: _nl_load_locale_from_archive defends incompletely against dividing by zero. Version-Release number of selected component (if applicable): glibc-2.24-59-g86ac4a7 How reproducible: every time (if particular corruption in locale archive) Steps to Reproduce: 1. Inspect code for _nl_load_locale_from_archive() 2. 3. 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)) goto close_and_out; 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 uint32_t namehash_size; 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). Additional info:
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' of '25'. 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 glibc-2.26-65-ga76376df7c which is the source for glibc-2.26-16.fc27.x86_64
This message is a reminder that Fedora 27 is nearing its end of life. On 2018-Nov-30 Fedora will stop maintaining and issuing updates for Fedora 27. 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' of '27'. 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 27 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.
This bug appears to have been reported against 'rawhide' during the Fedora 30 development cycle. Changing version to '30.
Fixed in upstream ef21bd2d8c6805c0c186a01f7c5039189f51b8c4