Skip to content

Potential fix for code scanning alert no. 12: Potentially overflowing call to snprintf #5

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

rzr
Copy link
Owner

@rzr rzr commented May 22, 2025

Potential fix for https://github.com/rzr/z-wave-protocol-controller/security/code-scanning/12

To fix the issue, the return value of snprintf should be checked to ensure it does not exceed the remaining buffer size (dst_max_len - index). If the return value is negative or greater than or equal to the remaining space, the function should terminate early to prevent buffer overflow. This involves:

  1. Capturing the return value of snprintf in a variable.
  2. Validating the return value to ensure it is within bounds.
  3. Breaking out of the loop or returning an error code if the return value is invalid.

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

rzr and others added 5 commits May 22, 2025 17:25
Checking snprintf results, this was found using CodeQL

  Potential fix for code scanning alert no. 15:
  Potentially overflowing call to snprintf

For the record this function escape the git commit to hex form (in ascii)

Origin: SiliconLabsSoftware#104
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Relate-to: SiliconLabsSoftware#100
Signed-off-by: Philippe Coval <[email protected]>
This will align to SL policy

Signed-off-by: Philippe Coval <[email protected]>
Also added comment to prevent privileges escalation using pull_request_target (see related change)

Relate-to:SiliconLabsSoftware#67
Relate-to: https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
Signed-off-by: Philippe Coval <[email protected]>
…call to snprintf

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

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@rzr rzr force-pushed the main branch 18 times, most recently from 4f86970 to e24a30e Compare May 27, 2025 13:30
@rzr rzr force-pushed the main branch 7 times, most recently from 7c4a093 to cdc13a8 Compare June 3, 2025 09:57
@rzr rzr force-pushed the main branch 8 times, most recently from e7c64e2 to a86e78d Compare June 5, 2025 15:37
@rzr rzr force-pushed the main branch 9 times, most recently from 01d2815 to 1df056b Compare June 16, 2025 15:35
@rzr rzr force-pushed the main branch 6 times, most recently from eb732ac to 31cb0ba Compare June 23, 2025 12:04
@rzr rzr force-pushed the main branch 3 times, most recently from f91d9c4 to 8dcfa6b Compare July 10, 2025 07:23
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