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

fix: incorrect conversion between integer types #49

Merged
merged 3 commits into from
Jan 26, 2025

Conversation

wolf31o2
Copy link
Collaborator

Potential fix for https://github.com/Salvionied/apollo/security/code-scanning/1

To fix the problem, we need to ensure that the integer value parsed from the string is within the bounds of a uint32 before performing the conversion. This can be done by using strconv.ParseUint with a bit size of 32, which directly returns a uint64 that can be safely cast to uint32 after bounds checking.

  1. Replace the use of strconv.Atoi with strconv.ParseUint specifying a bit size of 32.
  2. Check the bounds of the parsed value to ensure it fits within the uint32 range.
  3. Perform the conversion to uint32 only after ensuring the value is within bounds.

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

wolf31o2 and others added 3 commits January 24, 2025 10:41
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
@wolf31o2 wolf31o2 changed the title Potential fix for code scanning alert no. 1: Incorrect conversion between integer types fix: incorrect conversion between integer types Jan 24, 2025
@wolf31o2 wolf31o2 marked this pull request as ready for review January 24, 2025 16:25
@wolf31o2 wolf31o2 merged commit af22a31 into master Jan 26, 2025
5 checks passed
@wolf31o2 wolf31o2 deleted the fix/incorrect-int-conversion branch January 26, 2025 12:16
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