Skip to content

Potential fix for code scanning alert no. 8: Potentially overflowing call to snprintf #9

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 2 commits into
base: main
Choose a base branch
from

Conversation

rzr
Copy link
Owner

@rzr rzr commented May 26, 2025

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

To fix the issue, we need to validate the return value of each snprintf call. If the return value is negative (indicating an encoding error) or greater than or equal to the remaining buffer size, we should stop appending to the buffer to prevent overflow. This involves:

  1. Storing the return value of snprintf in a variable.
  2. Checking if the return value is valid and within bounds.
  3. Breaking out of the loop or skipping further snprintf calls if the buffer is full or an error occurs.

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

rzr and others added 2 commits May 26, 2025 16:51
This issue was reported by CodeQL, IMHOI the alert was over reacting
because contents was already extracted in a separate directory (which
is absent in tree, so there is no risk to override)

An extra check would be to verify a signed asset (using GPG),
along a ZWA public key shared in tree.

Potential fix for code scanning alert no. 1: Artifact poisoning

Origin: SiliconLabsSoftware#108
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Relate-to: Z-Wave-Alliance/OSWG#48 (comment)
Relate-to: SiliconLabsSoftware#67
Relate-to: https://github.com/rzr/z-wave-protocol-controller/security/code-scanning/1
Relate-to: https://cwe.mitre.org/data/definitions/829.html
Releta-to: SiliconLabsSoftware#100
Signed-off-by: Philippe Coval <philippe.coval@silabs.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 11 times, most recently from 02155b9 to c1e7488 Compare June 2, 2025 15:17
@rzr rzr force-pushed the main branch 10 times, most recently from e7c64e2 to a86e78d Compare June 5, 2025 15:37
@rzr rzr force-pushed the main branch 7 times, most recently from f24e8cf to 8787f76 Compare June 16, 2025 14:09
@rzr rzr force-pushed the main branch 8 times, most recently from eb732ac to 31cb0ba Compare June 23, 2025 12:04
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