#!/bin/sh # # Patch ElectricFence-2.1 to work when using $EFENCE in src/SpeedyMake.pl # patch < 0 ) memcpy(newBuffer, oldBuffer, size); ! free(oldBuffer); noAllocationListProtection = 0; Page_DenyAccess(allocationList, allocationListSize); if ( size < newSize ) memset(&(((char *)newBuffer)[size]), 0, newSize - size); /* Internal memory was re-protected in free() */ } --- 723,736 ---- if ( size > 0 ) memcpy(newBuffer, oldBuffer, size); ! efence_free(oldBuffer); noAllocationListProtection = 0; Page_DenyAccess(allocationList, allocationListSize); + /* We want garbage left in the new buffer. if ( size < newSize ) memset(&(((char *)newBuffer)[size]), 0, newSize - size); + */ /* Internal memory was re-protected in free() */ } *************** *** 729,747 **** } extern C_LINKAGE void * ! malloc(size_t size) { if ( allocationList == 0 ) initialize(); /* This sets EF_ALIGNMENT */ ! return memalign(EF_ALIGNMENT, size); } extern C_LINKAGE void * ! calloc(size_t nelem, size_t elsize) { size_t size = nelem * elsize; ! void * allocation = malloc(size); memset(allocation, 0, size); return allocation; --- 739,757 ---- } extern C_LINKAGE void * ! efence_malloc(size_t size) { if ( allocationList == 0 ) initialize(); /* This sets EF_ALIGNMENT */ ! return efence_memalign(EF_ALIGNMENT, size); } extern C_LINKAGE void * ! efence_calloc(size_t nelem, size_t elsize) { size_t size = nelem * elsize; ! void * allocation = efence_malloc(size); memset(allocation, 0, size); return allocation; *************** *** 752,758 **** * will break some software. */ extern C_LINKAGE void * ! valloc (size_t size) { ! return memalign(bytesPerPage, size); } --- 762,768 ---- * will break some software. */ extern C_LINKAGE void * ! efence_valloc (size_t size) { ! return efence_memalign(bytesPerPage, size); } diff -c ./eftest.c ../ElectricFence-2.1/eftest.c *** ./eftest.c Thu Jan 19 20:54:30 1995 --- ../ElectricFence-2.1/eftest.c Sat May 31 18:16:26 2003 *************** *** 77,83 **** static int allocateMemory(void) { ! allocation = (char *)malloc(1); if ( allocation != 0 ) return 0; --- 77,83 ---- static int allocateMemory(void) { ! allocation = (char *)efence_malloc(1); if ( allocation != 0 ) return 0; *************** *** 88,94 **** static int freeMemory(void) { ! free(allocation); return 0; } --- 88,94 ---- static int freeMemory(void) { ! efence_free(allocation); return 0; } diff -c ./page.c ../ElectricFence-2.1/page.c *** ./page.c Fri Apr 26 15:57:38 1996 --- ../ElectricFence-2.1/page.c Sat May 31 18:16:26 2003 *************** *** 31,37 **** #if ( !defined(sgi) && !defined(_AIX) ) extern int sys_nerr; ! extern char * sys_errlist[]; #endif static const char * --- 31,37 ---- #if ( !defined(sgi) && !defined(_AIX) ) extern int sys_nerr; ! extern const char * const sys_errlist[]; #endif static const char *