--- glibc-2.1.3/malloc/malloc.c.org Wed Feb 23 08:02:55 2000 +++ glibc-2.1.3/malloc/malloc.c Thu Jul 5 15:03:53 2001 @@ -2975,6 +2975,13 @@ */ +/* for wiping free'd blocks with zeroes */ +#define SINA_MALLOC_WIPED_FREE 1 + + +#ifdef SINA_MALLOC_WIPED_FREE +static char sinaoptions[] = "SINA_MALLOC_WIPED_FREE"; +#endif /* SINA_MALLOC_WIPED_FREE */ #if __STD_C void fREe(Void_t* mem) @@ -2985,6 +2992,10 @@ arena *ar_ptr; mchunkptr p; /* chunk corresponding to mem */ +#ifdef SINA_MALLOC_WIPED_FREE + INTERNAL_SIZE_T csz; +#endif /* SINA_MALLOC_WIPED_FREE */ + #if defined _LIBC || defined MALLOC_HOOKS if (__free_hook != NULL) { #if defined __GNUC__ && __GNUC__ >= 2 @@ -3020,6 +3031,21 @@ #else (void)mutex_lock(&ar_ptr->mutex); #endif + +#ifdef SINA_MALLOC_WIPED_FREE + csz = chunksize(p); + /* size for zero should be only one minus, while the chunk is in use + * and therefor footer is not used; + * I hope so ;-| + */ + + /* + fprintf(stderr, "wiped_free: clear chunk (addr: %x size: %d)\n", mem, csz-SIZE_SZ); + */ + + MALLOC_ZERO(mem, csz - SIZE_SZ); +#endif /* SINA_MALLOC_WIPED_FREE */ + chunk_free(ar_ptr, p); (void)mutex_unlock(&ar_ptr->mutex); }