Repository navigation
firmware: don't truncate tar content_end on binary payloads - #280
Conversation
detect_tar_md5_info() finds the block-aligned MD5 trailer correctly, but then unconditionally scanned back through the 64 KiB tail for '\n'. Any 0x0A byte in the preceding TAR payload (common in lz4 images) moved content_end into the archive data, so MD5 verification failed on valid firmware, e.g. A325FXXSCDYB2 (all four archives). A TAR archive always ends on a 512-byte boundary, so a block-aligned MD5 is the trailer start as-is. The newline scan now runs only for the non-aligned fallback, and never crosses the preceding 512-byte boundary. The trailer location logic moves into a dependency-free header (src/firmware/tar_md5_trailer.h) so it can be unit tested; behaviour of detect_tar_md5_info() is otherwise unchanged. Fixes Llucs#279 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HHr8mBtQ7BuQgtfG1QS8iC
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds a shared TAR MD5 trailer locator and uses it in firmware package detection. The locator prefers block-aligned MD5 candidates and bounds newline scanning for unaligned candidates. New tests cover candidate positions, payload alignment, and missing or short trailer data. ChangesTAR MD5 trailer detection
Priority: ⬆️ High Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to This PR changes TAR MD5 boundary detection to avoid payload newlines truncating the verified range and adds focused alignment and fallback tests. No specific user-facing regression is supported by the supplied context, so merge risk is minimal. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change corrects which archive bytes are checked without an identified weakening of firmware verification. The available evidence does not establish every way an archive might be supplied. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Address the CodeRabbit docstring-coverage warning on Llucs#280: - doc comments for is_hex_char(), TrailerPos, locate_trailer(), detect_tar_md5_info() and every test helper / test case New tests: - uppercase_md5: upper-case hex digits are accepted as a trailer - trailer_only: a file holding only the trailer yields md5_pos == 0 and content_end == 0 (rejected later by verify_tar_md5()) No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HHr8mBtQ7BuQgtfG1QS8iC
|
@coderabbitai full review |
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai which functions touched by this PR are counted as missing docstrings for the Docstring Coverage check? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -u
gh pr checks 280 --repo Llucs/odin4 || true
gh api repos/Llucs/odin4/pulls/280/files --paginate --jq '.[] | {filename,status,patch}'Length of output: 15377 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' 'REPO MATCHES'
rg -n -i -C2 'docstring.coverage|docstring|documentation.coverage' --glob '!*.lock' . | head -140 || true
printf '%s\n' 'PR DETAILS'
gh pr view 280 --repo Llucs/odin4 --json headRefOid,statusCheckRollup,reviews,comments --jq '{headRefOid, statusCheckRollup, reviews: [.reviews[] | {author:.author.login,body:.body}], comments: [.comments[] | {author:.author.login,body:.body}]}' | head -c 20000
printf '\n%s\n' 'CHECK RUNS'
oid=$(gh pr view 280 --repo Llucs/odin4 --json headRefOid --jq .headRefOid)
gh api "repos/Llucs/odin4/commits/$oid/check-runs" --jq '.check_runs[] | {name,conclusion,details_url,output:.output}' | head -c 30000Length of output: 13069 🤖 web_search executed:
Length of output: 7036
The diff shows two plausible candidates: the You are interacting with an AI system. |
detect_tar_md5_info() finds the block-aligned MD5 trailer correctly, but then unconditionally scanned back through the 64 KiB tail for '\n'. Any 0x0A byte in the preceding TAR payload (common in lz4 images) moved content_end into the archive data, so MD5 verification failed on valid firmware, e.g. A325FXXSCDYB2 (all four archives).
A TAR archive always ends on a 512-byte boundary, so a block-aligned MD5 is the trailer start as-is. The newline scan now runs only for the non-aligned fallback, and never crosses the preceding 512-byte boundary.
The trailer location logic moves into a dependency-free header (src/firmware/tar_md5_trailer.h) so it can be unit tested; behaviour of detect_tar_md5_info() is otherwise unchanged.
Fixes #279
Claude-Session: https://claude.ai/code/session_01HHr8mBtQ7BuQgtfG1QS8iC
Summary
Type of change
Testing
Notes
Unit tests: tests/test_tar_md5_trailer.cpp (10 cases), odin4_tests 47/47 pass.
Summary by CodeRabbit
.tar.md5firmware packages, including trailers at aligned or unaligned positions.