Repository navigation
chore(review): adversarial code review of cpp23 wave (PRs #41-#58) - #78
Merged
Merged
Conversation
lusoris
enabled auto-merge (squash)
May 28, 2026 20:45
lusoris
added a commit
that referenced
this pull request
May 28, 2026
…rse_int/parse_double (adversarial review PR #78) string_view is not guaranteed NUL-terminated; passing sv.data() directly to strtol/strtod is UB when sv is a substring view. Copy to std::string first. Fixes the CRITICAL finding flagged in adversarial review PR #78. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris
added a commit
that referenced
this pull request
May 28, 2026
… (adversarial review PR #78) strlen(model->name) - 5U + 1U wraps to a huge size_t when strlen < 5. Add early-return -EINVAL guard before the subtraction. The suffix-strip logic is only valid for names longer than 5 chars anyway. Fixes the CRITICAL finding in adversarial review PR #78. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris
added a commit
that referenced
this pull request
May 28, 2026
…in vmaf_ref_close (adversarial review PR #78) make_unique uses operator new; vmaf_ref_close (C ABI) must use free() to match the legacy allocator contract and keep ref.c (test harness) and ref.cpp consistent. Switch to malloc+placement-new and document in ref.h that vmaf_ref_close is the sole valid deallocator. Fixes the CRITICAL allocator-mismatch finding in adversarial review PR #78. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced May 28, 2026
Read-only adversarial review of the C to C++23 conversion wave. Found 4 CRITICAL, 2 HIGH, 10 MEDIUM, 3 LOW issues across all 9 PRs. No code changes; documentation and findings only. Critical findings: - PR #48 dict.cpp: strtof (float) assigned to double, precision loss on option values causes potential score corruption - PR #54 model.cpp: strlen(model->name) - 5U unsigned underflow can produce SIZE_MAX-4 calloc size, heap overflow - PR #58 ref.cpp: make_unique/operator-new but C callers may free(), allocator mismatch is UB / heap corruption - PR #43 opt.cpp: string_view::data() passed to strtol without guaranteed NUL-termination All findings documented in docs/research/cpp23-wave-adversarial-review-20260528.md. Recurring smell pattern added to core/AGENTS.md invariant list. state.md row added. rebase-notes entry added. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris
force-pushed
the
chore/cpp23-wave-adversarial-review-20260528
branch
from
May 28, 2026 21:35
6027eb2 to
2779ab5
Compare
lusoris
added a commit
that referenced
this pull request
May 28, 2026
…rse_int/parse_double (adversarial review PR #78) string_view is not guaranteed NUL-terminated; passing sv.data() directly to strtol/strtod is UB when sv is a substring view. Copy to std::string first. Fixes the CRITICAL finding flagged in adversarial review PR #78. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris
added a commit
that referenced
this pull request
May 28, 2026
… (adversarial review PR #78) strlen(model->name) - 5U + 1U wraps to a huge size_t when strlen < 5. Add early-return -EINVAL guard before the subtraction. The suffix-strip logic is only valid for names longer than 5 chars anyway. Fixes the CRITICAL finding in adversarial review PR #78. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris
added a commit
that referenced
this pull request
May 28, 2026
…in vmaf_ref_close (adversarial review PR #78) make_unique uses operator new; vmaf_ref_close (C ABI) must use free() to match the legacy allocator contract and keep ref.c (test harness) and ref.cpp consistent. Switch to malloc+placement-new and document in ref.h that vmaf_ref_close is the sole valid deallocator. Fixes the CRITICAL allocator-mismatch finding in adversarial review PR #78. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris
added a commit
that referenced
this pull request
May 28, 2026
…rse_int/parse_double (adversarial review PR #78) (#43) string_view is not guaranteed NUL-terminated; passing sv.data() directly to strtol/strtod is UB when sv is a substring view. Copy to std::string first. Fixes the CRITICAL finding flagged in adversarial review PR #78. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris
added a commit
that referenced
this pull request
May 28, 2026
… (adversarial review PR #78) (#54) strlen(model->name) - 5U + 1U wraps to a huge size_t when strlen < 5. Add early-return -EINVAL guard before the subtraction. The suffix-strip logic is only valid for names longer than 5 chars anyway. Fixes the CRITICAL finding in adversarial review PR #78. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
lusoris
added a commit
that referenced
this pull request
May 28, 2026
…in vmaf_ref_close (adversarial review PR #78) (#58) make_unique uses operator new; vmaf_ref_close (C ABI) must use free() to match the legacy allocator contract and keep ref.c (test harness) and ref.cpp consistent. Switch to malloc+placement-new and document in ref.h that vmaf_ref_close is the sole valid deallocator. Fixes the CRITICAL allocator-mismatch finding in adversarial review PR #78. Co-authored-by: Claude Sonnet 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
core/AGENTS.mdto prevent recurrence.Critical findings
core/src/opt.cppstring_view::data()passed tostrtol/strtodwithout guaranteed NUL-termination — UB if a substringstring_viewis ever passedcore/src/dict.cppstrtof(returnsfloat) assigned todouble dv— precision loss when high-precision option strings are round-tripped throughsnprintf("%g", dv)core/src/model.cppstrlen(model->name) - 5Uwraps toSIZE_MAX-4when name is shorter than 5 chars; downstreamcalloc(1, SIZE_MAX-4)→ heap overflowcore/src/ref.cppstd::make_unique<VmafRef>()allocates viaoperator new; C callers that callfree(ref_ptr)directly (pre-existing pattern) will corrupt the heapTest plan
gh pr diff 41 43 44 45 48 51 54 56 58 -R VMAFx/vmafxreproduces all diffs reviewed.Deep-dive deliverables (ADR-0108)
docs/research/cpp23-wave-adversarial-review-20260528.mdcore/AGENTS.mdinvariant note: C→C++ conversion safety checklist addedgh pr diff <N> -R VMAFx/vmafx > /tmp/pr-<N>.difffor N in {41,43,44,45,48,51,54,56,58}changelog.d/changed/cpp23-wave-adversarial-review.mddocs/rebase-notes.mdentry addeddocs/state.mdrow: "cpp23 wave adversarial review (this PR); 4 critical, 2 high, 10 medium"no rebase impact: read-only review PR; no Netflix upstream surface touched.
🤖 Generated with Claude Code