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

Prevent integer overflow in FindAutomorphismIndex2nComplex() #918

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

dsuponitskiy
Copy link
Collaborator

@dsuponitskiy dsuponitskiy commented Dec 4, 2024

  1. Changed the type of g0 and g from int32_t to uint64_t:
    • to prevent integer overflow if the result of (g*g0) is too high
    • NativeInteger().ModInverse() always returns positive number, so the type can be unsigned
  2. Replaced "if (i == int32_t(m - 1))" with "if (i == (static_cast<int32_t>(m) - 1))" as the subtraction should be performed on int32_t to avoid unexpected behavior.
  3. Replaced the C-style cast with the C++ one

@dsuponitskiy dsuponitskiy added the bug Something isn't working label Dec 4, 2024
@dsuponitskiy dsuponitskiy added this to the Release 1.3.0 milestone Dec 4, 2024
@dsuponitskiy dsuponitskiy self-assigned this Dec 4, 2024
@dsuponitskiy dsuponitskiy linked an issue Dec 4, 2024 that may be closed by this pull request
@yspolyakov yspolyakov merged commit 6e8feea into tmp-dev Dec 12, 2024
26 checks passed
@dsuponitskiy dsuponitskiy deleted the 901-integer-overflow branch January 3, 2025 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integer overflow in FindAutomorphismIndex2nComplex
3 participants