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. 683: Suspicious add with sizeof #130

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

cooljeanius
Copy link
Owner

Fixes https://github.com/cooljeanius/apple-gdb-1824/security/code-scanning/683

To fix the problem, we need to ensure that the pointer arithmetic is done correctly. Instead of adding sizeof(ext_ldmbuf_partial) to the pointer, we should add the number of elements. This can be achieved by casting the pointer to a gdb_byte * type before performing the arithmetic. This way, the arithmetic will be done in terms of bytes, which is the intended behavior.

  • Change the pointer arithmetic on line 143 to cast the pointer to gdb_byte * before adding the offset.
  • Ensure that the rest of the code remains unchanged to maintain existing functionality.

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

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@cooljeanius cooljeanius marked this pull request as ready for review October 4, 2024 16:20
Copy link
Owner Author

@cooljeanius cooljeanius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh... ok, I guess...

@cooljeanius cooljeanius merged commit b9570fc into master Oct 4, 2024
26 checks passed
@cooljeanius cooljeanius deleted the autofix/alert-683-d616f5a220 branch October 4, 2024 16:21
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