Skip to content

Conversation

@Fabio3rs
Copy link
Owner

Potential fix for https://github.com/Fabio3rs/cppapiframework/security/code-scanning/1

To resolve the issue, replace the use of std::gmtime in the format function with its thread-safe variant. On platforms where gmtime_r is available (POSIX), it should be used instead; on Windows, use gmtime_s. Since we need to allocate a tm struct on the stack and pass its pointer to the respective function, this fits well. If the codebase needs to remain portable across platforms, a preprocessor check can be added to select the correct version.

Specifically:

  • Edit the format function in src/PistacheCustomHttpHeaders/LastModified.hpp at lines 39-46.
  • Allocate a tm tm_time struct on the stack.
  • Replace std::gmtime(&cftime) with a thread-safe alternative, using gmtime_r where available and gmtime_s on MSVC/Windows.
  • Pass a pointer to the local tm struct to strftime.

You may also need to include <ctime>/<time.h> and possibly include guards for platform-specific code.


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

…rous function

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Fabio3rs Fabio3rs marked this pull request as ready for review August 26, 2025 17:25
@Fabio3rs Fabio3rs merged commit df51967 into main Aug 26, 2025
@Fabio3rs Fabio3rs deleted the alert-autofix-1 branch September 3, 2025 12:48
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.

2 participants