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. 213: Use of potentially dangerous function #292

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nibanks
Copy link
Member

@nibanks nibanks commented Dec 27, 2024

Fixes https://github.com/microsoft/quicreach/security/code-scanning/213

To fix the problem, we should replace the call to gmtime with gmtime_r, which is a thread-safe alternative. The gmtime_r function requires the caller to provide a tm structure where the result will be stored, thus avoiding the use of shared static memory.

  • Replace the call to gmtime with gmtime_r.
  • Allocate a tm structure on the stack and pass it to gmtime_r.
  • Update the code to use the stack-allocated tm structure.

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>
@nibanks nibanks marked this pull request as ready for review December 27, 2024 19:34
@nibanks nibanks enabled auto-merge (squash) December 27, 2024 19:35
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