Skip to content

fix: prevent integer overflow in e2store entry data length#18772

Closed
avorylli wants to merge 3 commits intoparadigmxyz:mainfrom
avorylli:fix-e2store-integer-overflow
Closed

fix: prevent integer overflow in e2store entry data length#18772
avorylli wants to merge 3 commits intoparadigmxyz:mainfrom
avorylli:fix-e2store-integer-overflow

Conversation

@avorylli
Copy link
Copy Markdown
Contributor

Fix potential integer overflow when converting usize to u32 in e2store file operations.

Changes:

  • Add safe type conversion using TryFrom in Entry::write() method
  • Add safe type conversion in Era1Reader::read() for offset count
  • Return descriptive error messages when data exceeds u32::MAX

Why this change is necessary:

The e2store file format specification limits entry data length to u32::MAX (4GB).

Previously, direct casting from usize to u32 could cause silent integer overflow on 64-bit systems when data.len() > u32::MAX, leading to incorrect header values and potential data corruption.

Copy link
Copy Markdown
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt necessary, we dont expect > u32 entries here

@mattsse mattsse closed this Sep 30, 2025
@github-project-automation github-project-automation bot moved this from Backlog to Done in Reth Tracker Sep 30, 2025
dhyaniarun1993 pushed a commit to op-rs/op-reth that referenced this pull request Jan 14, 2026
Part of #483.

First wait for theo's PR
[paradigmxyz#18754](ethereum-optimism/optimism#18754) to be
merged.
Then wait for our PR
[paradigmxyz#18772](ethereum-optimism/optimism#18772) to be
merged.

After that, in this repo, remove the current submodule and replace it
with optimism itself.
emhane pushed a commit to op-rs/op-reth that referenced this pull request Jan 15, 2026
Part of #483.

First wait for theo's PR
[paradigmxyz#18754](ethereum-optimism/optimism#18754) to be
merged.
Then wait for our PR
[paradigmxyz#18772](ethereum-optimism/optimism#18772) to be
merged.

After that, in this repo, remove the current submodule and replace it
with optimism itself.
emhane pushed a commit to op-rs/op-reth that referenced this pull request Jan 20, 2026
Part of #483.

First wait for theo's PR
[paradigmxyz#18754](ethereum-optimism/optimism#18754) to be
merged.
Then wait for our PR
[paradigmxyz#18772](ethereum-optimism/optimism#18772) to be
merged.

After that, in this repo, remove the current submodule and replace it
with optimism itself.
emhane pushed a commit to op-rs/op-reth that referenced this pull request Jan 26, 2026
Part of #483.

First wait for theo's PR
[paradigmxyz#18754](ethereum-optimism/optimism#18754) to be
merged.
Then wait for our PR
[paradigmxyz#18772](ethereum-optimism/optimism#18772) to be
merged.

After that, in this repo, remove the current submodule and replace it
with optimism itself.
emhane pushed a commit to op-rs/op-reth that referenced this pull request Jan 29, 2026
Part of #483.

First wait for theo's PR
[paradigmxyz#18754](ethereum-optimism/optimism#18754) to be
merged.
Then wait for our PR
[paradigmxyz#18772](ethereum-optimism/optimism#18772) to be
merged.

After that, in this repo, remove the current submodule and replace it
with optimism itself.
emhane pushed a commit to op-rs/op-reth that referenced this pull request Jan 29, 2026
Part of #483.

First wait for theo's PR
[paradigmxyz#18754](ethereum-optimism/optimism#18754) to be
merged.
Then wait for our PR
[paradigmxyz#18772](ethereum-optimism/optimism#18772) to be
merged.

After that, in this repo, remove the current submodule and replace it
with optimism itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants