diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-23 22:30:43 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-23 22:30:43 +0000 |
commit | 4029c07550295659b391220324f348f4b1a86381 (patch) | |
tree | ba6800f109598f4d12e3bfa089caec7fa8acc9dc /src/util/common_allocation.c | |
parent | bc0c61a40a5c68c1fbefc475735e88788e6b1bc4 (diff) | |
download | gnunet-4029c07550295659b391220324f348f4b1a86381.tar.gz gnunet-4029c07550295659b391220324f348f4b1a86381.zip |
-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.
Diffstat (limited to 'src/util/common_allocation.c')
-rw-r--r-- | src/util/common_allocation.c | 11 |
1 files changed, 11 insertions, 0 deletions
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 | |||
@@ -198,6 +198,17 @@ GNUNET_xfree_ (void *ptr, const char *filename, int linenumber) | |||
198 | ptr = &((size_t *) ptr)[-1]; | 198 | ptr = &((size_t *) ptr)[-1]; |
199 | mem_used -= *((size_t *) ptr); | 199 | mem_used -= *((size_t *) ptr); |
200 | #endif | 200 | #endif |
201 | #if WINDOWS | ||
202 | #if ENABLE_POISONING | ||
203 | { | ||
204 | size_t i; | ||
205 | char baadfood[4] = "\xBA\xAD\xF0\x0D"; | ||
206 | size_t s = _msize (ptr); | ||
207 | for (i = 0; i < s; i++) | ||
208 | ((char *) ptr)[i] = baadfood[i % 4]; | ||
209 | } | ||
210 | #endif | ||
211 | #endif | ||
201 | free (ptr); | 212 | free (ptr); |
202 | } | 213 | } |
203 | 214 | ||