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

Review indexing from intergers to make sure we don't allow unintentional overflows #145

Closed
alerque opened this issue Nov 9, 2024 · 2 comments

Comments

@alerque
Copy link
Member

alerque commented Nov 9, 2024

There are a few other instances of this exact construct as well as a large number of as invocations on integer types that are not very safe or idiomatic. That doesn't necessarily mean it is even possible to trigger other issues like this one, but it does mean there could be a little more defensive coding here.

Originally posted by @alerque in #142 (comment)

I did a quick pass looking for other potential instances of similar overflows and see a few potential cases. I did not review the larger context to figure out whether the potential overflow is a reachable code path, only the local context of the integer handling.

Unfortunately in playing with "fixing" these it became obvious the cases are not all covered by existing test. For example one can delete this line of code entirely and the test suite still just passes:

delta += match_positions[idx] as isize - end as isize;

@behdad
Copy link
Member

behdad commented Nov 9, 2024

See #142 (comment)

@alerque
Copy link
Member Author

alerque commented Nov 9, 2024

Reopened #142 for tracking, all discussion is there.

@alerque alerque closed this as completed Nov 9, 2024
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

No branches or pull requests

2 participants