mirror of
https://github.com/AGWA/git-crypt.git
synced 2026-01-01 15:49:58 -08:00
Ensure memsets of sensitive memory aren't optimized away
This commit is contained in:
11
util.cpp
11
util.cpp
@@ -81,6 +81,17 @@ void write_be32 (std::ostream& out, uint32_t i)
|
||||
out.write(reinterpret_cast<const char*>(buffer), 4);
|
||||
}
|
||||
|
||||
void* explicit_memset (void* s, int c, std::size_t n)
|
||||
{
|
||||
volatile unsigned char* p = reinterpret_cast<unsigned char*>(s);
|
||||
|
||||
while (n--) {
|
||||
*p++ = c;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static void init_std_streams_platform (); // platform-specific initialization
|
||||
|
||||
void init_std_streams ()
|
||||
|
||||
Reference in New Issue
Block a user