Skip to content

Conversation

ptrgits
Copy link

@ptrgits ptrgits commented Aug 12, 2025

fix this problem, the call to memset should be replaced with a function that is guaranteed not to be optimized away by the compiler. The best standard solution is to use memset_s (from C11), which is specifically designed for this purpose. If memset_s is not available on all target platforms, a fallback to a platform-specific secure zeroing function (such as explicit_bzero or SecureZeroMemory on Windows) or a custom implementation may be necessary. However, since we can only edit the code shown, the best fix is to replace memset with memset_s and include the required header (#include <string.h>, already present). If memset_s is not available, the build will fail, prompting the developer to provide an appropriate implementation.

Steps:

  • Replace the call to memset(block, '\0', sizeof(block)); with memset_s(block, sizeof(block), 0, sizeof(block)); in src/sha1.c.
  • No additional imports are needed, as <string.h> is already included.
  • No other code changes are required within the shown code.

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