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 code scanning alert no. 67: Multiplication result converted to larger type #1392

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tsteven4
Copy link
Collaborator

@tsteven4 tsteven4 commented Dec 3, 2024

Fixes https://github.com/GPSBabel/gpsbabel/security/code-scanning/67

To fix the problem, we need to ensure that the multiplication is performed using the larger type (qsizetype) before the result is assigned. This can be achieved by casting one of the operands to qsizetype before performing the multiplication. This way, the multiplication will be done using the larger type, preventing overflow.

  • Cast one of the operands (members or size) to qsizetype before the multiplication.
  • Update the code on line 698 to perform the multiplication using the larger type.

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

…rger type

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copy link

codacy-production bot commented Dec 3, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.01% 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (a460fb5) 27548 17225 62.53%
Head commit (c33de6c) 55105 (+27557) 34459 (+17234) 62.53% (+0.01%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#1392) 1 1 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

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