fix: harden encoder/decoder against UB, data races, and corrupted input#57
Open
facontidavide wants to merge 1 commit intomainfrom
Open
fix: harden encoder/decoder against UB, data races, and corrupted input#57facontidavide wants to merge 1 commit intomainfrom
facontidavide wants to merge 1 commit intomainfrom
Conversation
Address issues found during code review: - Fix decodeVarint shift UB: check overflow before shift operation - Fix decodeVarint underflow: guard against uval==0 on corrupted data - Fix worker thread deadlock: detect dead worker on subsequent encode() - Fix WASM encode: avoid extra allocation by encoding directly when buffer fits - Clean up waitForCompressionComplete: only set worker_failed_ in error path - Optimize encode(BufferView&): use header_.size() instead of YAML reserialization - Improve readability and error messages in DecodeHeader/MaxSerializedFieldSize - Add explicit <cstring> include in encoding_utils.hpp - Fix pre-existing FloatLossy test bug: use float instead of double for kResolution - Re-enable previously commented-out tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
uval==0(corrupted data) wrappinguint64_ttoUINT64_MAXencode()calls instead of hanging foreverMaxCompressedSizefirst and encode directly into caller's buffer when it fits, avoiding unnecessary heap allocation + memcpyworker_failed_(notcompression_done_) in catch block for clearer signal separationencode(BufferView&): useheader_.size()directly instead of re-serializing YAML viaMaxCompressedSizeMaxSerializedFieldSizeerrors<cstring>include: makememcpydependency explicit inencoding_utils.hppkResolutionwasdouble, causing CTAD to deduce<double>template onfloatdata — changed tofloattest_field_encoders.cpp,test_intrinsics.cpp,test_header.cppin CMakeLists and removeskip-testsfrom CITest plan
🤖 Generated with Claude Code