Merge pull request 'fix(build): add memset_explicit C shim for Windows MinGW libsodium linking' (#117) from fix/cargo-config-sodium into beta
Some checks failed
Test / frontend-typecheck (push) Successful in 1m57s
Test / rust-fmt-check (push) Successful in 17m42s
Release Beta / autotag (push) Successful in 9s
Release Beta / build-linux-amd64 (push) Successful in 10m46s
Test / rust-clippy (push) Successful in 19m30s
Release Beta / build-macos-arm64 (push) Failing after 17m52s
Release Beta / changelog (push) Successful in 1m18s
Release Beta / build-windows-amd64 (push) Failing after 10m58s
Test / rust-tests (push) Successful in 21m12s
Test / frontend-tests (push) Successful in 1m48s
Release Beta / build-linux-arm64 (push) Successful in 12m47s
Some checks failed
Test / frontend-typecheck (push) Successful in 1m57s
Test / rust-fmt-check (push) Successful in 17m42s
Release Beta / autotag (push) Successful in 9s
Release Beta / build-linux-amd64 (push) Successful in 10m46s
Test / rust-clippy (push) Successful in 19m30s
Release Beta / build-macos-arm64 (push) Failing after 17m52s
Release Beta / changelog (push) Successful in 1m18s
Release Beta / build-windows-amd64 (push) Failing after 10m58s
Test / rust-tests (push) Successful in 21m12s
Test / frontend-tests (push) Successful in 1m48s
Release Beta / build-linux-arm64 (push) Successful in 12m47s
Reviewed-on: #117
This commit is contained in:
commit
144c811a7a
@ -1,28 +1,14 @@
|
||||
// Shim for memset_explicit on MinGW which doesn't provide it
|
||||
// This is needed for libsodium's secure memory clearing
|
||||
|
||||
#if defined(_WIN32) && defined(__MINGW32__)
|
||||
/* memset_explicit shim for Windows MinGW
|
||||
*
|
||||
* libsodium-sys-stable expects memset_explicit which isn't available
|
||||
* in the MinGW runtime. This provides a compatible implementation.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// memset_explicit is available in Windows 8+ but MinGW headers don't always declare it
|
||||
// Provide a fallback implementation using SecureZeroMemory if available,
|
||||
// or a volatile memset to prevent compiler optimization
|
||||
void *memset_explicit(void *s, int c, size_t n) {
|
||||
// Try to use Windows API if available
|
||||
#ifdef _WIN32_WINNT
|
||||
#if _WIN32_WINNT >= 0x0602 // Windows 8+
|
||||
extern void *memset_s(void *, size_t, int, size_t);
|
||||
return memset_s(s, n, c, n);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Fallback: use volatile to prevent optimization
|
||||
volatile unsigned char *p = (volatile unsigned char *)s;
|
||||
void memset_explicit(void *dest, int val, size_t n) {
|
||||
volatile unsigned char *p = (volatile unsigned char *)dest;
|
||||
while (n--) {
|
||||
*p++ = (unsigned char)c;
|
||||
*p++ = (unsigned char)val;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user