Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dfu): buffer overflow #166

Merged
merged 1 commit into from
Jan 28, 2025
Merged

fix(dfu): buffer overflow #166

merged 1 commit into from
Jan 28, 2025

Conversation

fouge
Copy link
Collaborator

@fouge fouge commented Jan 22, 2025

When loading dfu data, if the block_count was larger than what the partition can accept, the processing thread would exit with an error without resetting its internal dfu_state, and thus the wr_idx. This allowed to write after the buffer boundaries.

Internal state is now reset, and wr_idx and data size always checked before writing the buffer.

Unit tests have been added to validate DFU logic, including valid and edge case scenarios for sequencing, buffer integrity, and semaphore handling.

fixes SEC-1325

@fouge fouge requested review from eth44, ik-work-gh and sri9311 January 22, 2025 12:35
When loading dfu data, if the block_count was larger than what the
partition can accept, the processing thread would exit with an error
without resetting its internal `dfu_state`, and thus the `wr_idx`. This
allowed to write after the buffer boundaries.

Internal state is now reset, and wr_idx and data size always checked
before writing the buffer.

Unit tests have been added to validate DFU logic, including valid and
edge case scenarios for sequencing, buffer integrity, and semaphore
handling.

Signed-off-by: Cyril Fougeray <[email protected]>
@fouge fouge force-pushed the fouge/fix-dfu-buffer-overflow branch from 98216fe to 7d538c1 Compare January 22, 2025 14:03
@fouge fouge merged commit c809717 into main Jan 28, 2025
11 checks passed
@fouge fouge deleted the fouge/fix-dfu-buffer-overflow branch January 28, 2025 17:31
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