Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5597
MD5Engine::updateImpl()andMD4Engine::updateImpl()take astd::size_tlength but usedunsigned intloop counters. With more than 4 GB in a singleupdate()call,i + 63 < inputLennever becomes false and the call does not return. A second problem sits in the bit count:(UInt32) inputLen >> 29casts before shifting, so the high word of the length lost everything above bit 31 ofinputLen, and the digest was wrong even with wider counters.i,indexandpartLenarestd::size_t; the high word is(UInt32) (inputLen >> 29).testLargeInputinMD5EngineTestandMD4EngineTest(long tests,-long) hash 4 GB + 100 zero bytes from a read-only anonymousmmap, so no physical memory is used. Unix 64-bit only. Expected digests come frommd5sumandopenssl dgst -md4.Tests: without the fix both new tests hang; with it they pass. Foundation-testrunner -all passes except DirectoryWatcherTest (inotify is not available in my container; unrelated). ASan+UBSan clean on the MD tests; clang-tidy and cppcheck show no new findings.
Follow-up:
SHA1Engine::updateImpl()has the same(UInt32 ) count >> 29pattern; I left it out to keep this change small.AI disclosure: this change was prepared with an AI coding agent following AGENTS.md, and reviewed by me.