Skip to content

Prevent integer overflow in FindAutomorphismIndex2nComplex()#918

Merged
yspolyakov merged 2 commits intotmp-devfrom
901-integer-overflow
Dec 12, 2024
Merged

Prevent integer overflow in FindAutomorphismIndex2nComplex()#918
yspolyakov merged 2 commits intotmp-devfrom
901-integer-overflow

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
@dsuponitskiy dsuponitskiy deleted the 901-integer-overflow branch January 3, 2025 21:17
yspolyakov pushed a commit that referenced this pull request Apr 2, 2025
* Prevent integer overflow in FindAutomorphismIndex2nComplex()

* Optimized the modulus operation in FindAutomorphismIndex2nComplex()

---------

Co-authored-by: Dmitriy Suponitskiy <dsuponitskiy@dualitytech.com>
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