1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 16:25:06 +00:00

LibC: Add explicit_bzero()

This is a variant of bzero() that is guaranteed to not get optimized
away by the compiler. Useful for clearing out sensitive data.
This commit is contained in:
Andreas Kling 2021-01-09 20:04:18 +01:00
parent 4a83a37f79
commit 9a842ec419
2 changed files with 8 additions and 0 deletions

View file

@ -476,4 +476,11 @@ size_t strxfrm(char* dest, const char* src, size_t n)
dest[i] = '\0';
return i;
}
void explicit_bzero(void* ptr, size_t size)
{
memset(ptr, 0, size);
asm volatile("" ::
: "memory");
}
}