Skip to content

Conversation

@michaelbeale-IL
Copy link

Potential fix for https://github.com/IntelLabs/HEC-openfhe-development-test/security/code-scanning/36

To fix the overflow issue, we need to ensure the multiplication gap * i is performed in a type at least as wide as size_t (usually 64 bits), so that any intermediate result reflects the true value, not the overflowed value. This is done by casting either gap or i to size_t (or another suitably wide type such as uint64_t) before the multiplication. The index is then passed to the vector access as usual.

The fix should only update the line where gap * i is used, i.e., in both lines (*nativeVec)[gap * i] = ...; in the FitToNativeVector function for int64_t (and you may wish to align style with the other overload, if applicable). Only the multiplication should be changed, with as little disruption as possible.

No additional headers or imports are needed, as both std::size_t and uint64_t are available in standard C++.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…onverted to larger type

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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.

1 participant