Ensure memsets of sensitive memory aren't optimized away

This commit is contained in:
Andrew Ayer
2014-07-23 19:32:30 -07:00
parent 23ff272f7d
commit 477983f4bc
5 changed files with 17 additions and 4 deletions

View File

@@ -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 ()