Skip to content

Add data length validation for write_section and write_region#436

Open
simonrw wants to merge 1 commit intofix/axis-ordering-regionfrom
fix/write-data-length-validation
Open

Add data length validation for write_section and write_region#436
simonrw wants to merge 1 commit intofix/axis-ordering-regionfrom
fix/write-data-length-validation

Conversation

@simonrw
Copy link
Owner

@simonrw simonrw commented Feb 10, 2026

Summary

  • write_section used assert! which panics on insufficient data — replaced with Err return
  • write_region had no data length validation at all, risking out-of-bounds reads when the data slice was too small for the specified region
  • Added proper Err returns with descriptive messages for both

Stacked on #433

Test plan

  • All existing tests pass
  • Verify write_section returns Err instead of panicking on short data
  • Verify write_region returns Err on short data

🤖 Generated with Claude Code

Replace assert! in write_section with an Err return when the data slice
is too small for the requested range. Add equivalent validation to
write_region which previously had none, risking out-of-bounds reads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 37.50000% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.3%. Comparing base (4ba6af5) to head (274c0ba).

Files with missing lines Patch % Lines
fitsio/src/images.rs 37.5% 10 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
fitsio/src/images.rs 94.7% <37.5%> (-2.0%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants