fix: harden encoder/decoder against UB, data races, and corrupted input#57
Merged
facontidavide merged 5 commits intomainfrom Feb 21, 2026
Merged
fix: harden encoder/decoder against UB, data races, and corrupted input#57facontidavide merged 5 commits intomainfrom
facontidavide merged 5 commits 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>
…d safety - Add per-point bounds check in decodeChunk to replace per-field checks in fixed-size decoders (FieldDecoderCopy, FieldDecoderFloat_XOR), eliminating 12-14% decode overhead while maintaining safety - Keep per-field checks for variable-size decoders (Float_Lossy, FloatN_Lossy) where overhead is negligible relative to varint decoding - Fix encoder deadlock on re-use after worker thread failure by joining dead thread and re-spawning; protect shared state resets with mutex - Tighten decodeVarint overflow check from shift>=64 to shift>=63 - Derive point count from actual data size in ROS conversion instead of trusting metadata width*height to prevent over-allocation DoS Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1d3f433 to
084f2e2
Compare
python3-ament-package does not exist on Ubuntu 24.04. The setup-ros action and action-ros-ci already handle installing colcon and ament dependencies, matching the working Humble CI workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
084f2e2 to
62a14f7
Compare
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