From: Christian Grothoff Date: Sat, 23 Jun 2012 22:30:43 +0000 (+0000) Subject: -LRN: Poisoning: X-Git-Tag: initial-import-from-subversion-38251~12855 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4029c07550295659b391220324f348f4b1a86381;p=oweals%2Fgnunet.git -LRN: Poisoning: Poisons memory before freeing it. It uses msize() CRT function, which (i believe) is not available on other platforms. This patch was intended to make the output of the next patch (see below) more apparent. --- diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 5e1f75eb7..801eeeebc 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c @@ -197,6 +197,17 @@ GNUNET_xfree_ (void *ptr, const char *filename, int linenumber) #ifdef W32_MEM_LIMIT ptr = &((size_t *) ptr)[-1]; mem_used -= *((size_t *) ptr); +#endif +#if WINDOWS +#if ENABLE_POISONING + { + size_t i; + char baadfood[4] = "\xBA\xAD\xF0\x0D"; + size_t s = _msize (ptr); + for (i = 0; i < s; i++) + ((char *) ptr)[i] = baadfood[i % 4]; + } +#endif #endif free (ptr); }