Skip to content

fix(device-table): reject oversized entry counts - #45

Open
AbdulRehman77777 wants to merge 1 commit into
embeddedos-org:masterfrom
AbdulRehman77777:fix/device-table-count-validation
Open

fix(device-table): reject oversized entry counts#45
AbdulRehman77777 wants to merge 1 commit into
embeddedos-org:masterfrom
AbdulRehman77777:fix/device-table-count-validation

Conversation

@AbdulRehman77777

Copy link
Copy Markdown

Summary

Reject device tables whose declared memory-region or peripheral counts exceed their fixed array capacities.

Problem

eos_device_table_validate() previously checked the table magic, version, and CRC, but did not validate mem_region_count or periph_count.

A malformed device table could therefore have a valid CRC while declaring more entries than its fixed arrays can store.

Code that trusts a successful validation result could then iterate past the bounds of the memory-region or peripheral arrays.

Solution

Add structural validation for both count fields before accepting the table:

  • Reject mem_region_count > EOS_MAX_MEM_REGIONS
  • Reject periph_count > EOS_MAX_PERIPHERALS
  • Return the existing EOS_ERR_INVALID error for invalid structural metadata

Valid device tables and the public API remain unchanged.

Testing

  • Added regression coverage for oversized memory-region counts.
  • Added regression coverage for oversized peripheral counts.
  • Confirmed the regression failed before the production fix.
  • test_device_table: 8/8 passed after the fix.
  • ASan/UBSan targeted tests: 8/8 passed.
  • Unaffected CTest suite: 13/13 passed.
  • Full CTest: 13/14 due to the existing test_recovery link failure on upstream.
  • Config generation passed using the repository CI fixture.
  • git diff --check passed.
  • Independent review completed with no findings.

Impact / Limitations

This is a focused device-table validation fix with no API changes or new dependencies.

The existing unrelated test_recovery link failure and pre-existing compiler warnings are not addressed by this PR.

Signed-off-by: abdulrehman <ranaabdul7711@gmail.com>
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.

1 participant