dbhelpers.c 483 B

12345678910111213141516171819202122232425
  1. #include "dbhelpers.h"
  2. #include "includes.h"
  3. /* Erase data */
  4. void m_burn(void *data, unsigned int len) {
  5. #if defined(HAVE_MEMSET_S)
  6. memset_s(data, len, 0x0, len);
  7. #elif defined(HAVE_EXPLICIT_BZERO)
  8. explicit_bzero(data, len);
  9. #else
  10. /* Based on the method in David Wheeler's
  11. * "Secure Programming for Linux and Unix HOWTO". May not be safe
  12. * against link-time optimisation. */
  13. volatile char *p = data;
  14. if (data == NULL)
  15. return;
  16. while (len--) {
  17. *p++ = 0x0;
  18. }
  19. #endif
  20. }