Skip to content

program: Fix off-by-one error #369

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

Merged
merged 1 commit into from
Apr 11, 2025
Merged

Conversation

joncinque
Copy link
Contributor

Problem

A buffer with 166 bytes is counted as invalid, but a buffer with 167 bytes is ok. This doesn't really make sense, because a buffer with 167 bytes wouldn't have room for the first type in the TLV structure.

Summary of changes

Remove the off-by-one-error by changing <= to <.

NOTE: Since there's currently no situation where it makes sense to have an account with 166 or 167 bytes, this shouldn't have any end-user impact, but it's better for the code to be correct.

#### Problem

A buffer with 166 bytes is counted as invalid, but a buffer with 167
bytes is ok. This doesn't really make sense, because a buffer with 167
bytes wouldn't have room for the first type in the TLV structure.

#### Summary of changes

Remove the off-by-one-error by changing `<=` to `<`
@joncinque joncinque merged commit 480813f into solana-program:main Apr 11, 2025
20 checks passed
@joncinque joncinque deleted the off-by-one branch April 11, 2025 22:36
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