2
0

testmem.c 538 B

12345678910111213141516171819202122232425
  1. #include <stdint.h>
  2. #include <stddef.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #ifdef FUZZ_MSAN
  6. #include <stdio.h>
  7. static void fuzz_testmem_msan(void *data, size_t size)
  8. {
  9. /* This is a trick to force MemorySanitizer to evaluate the data at hand */
  10. FILE *fp = fopen("/dev/null", "wb");
  11. fwrite(data, size, 1, fp);
  12. fclose(fp);
  13. }
  14. #endif
  15. void fuzz_testmem(void *data, size_t size)
  16. {
  17. #ifdef FUZZ_MSAN
  18. fuzz_testmem_msan(data, size);
  19. #endif
  20. uint8_t *copy = malloc(size);
  21. memcpy(copy, data, size);
  22. free(copy);
  23. }