[ElectricFence/f17] Add a patch that implements malloc_usable_size - Resolves: #772306

Petr Machata pmachata at fedoraproject.org
Mon Mar 12 22:17:55 UTC 2012


commit fbefa30e1809e9d46b9bcbf07c57fece5f8c761a
Author: Petr Machata <pmachata at redhat.com>
Date:   Mon Mar 12 23:13:32 2012 +0100

    Add a patch that implements malloc_usable_size
    - Resolves: #772306

 ElectricFence-2.2.2-malloc_usable_size.patch |   47 ++++++++++++++++++++++++++
 ElectricFence.spec                           |    8 ++++-
 2 files changed, 54 insertions(+), 1 deletions(-)
---
diff --git a/ElectricFence-2.2.2-malloc_usable_size.patch b/ElectricFence-2.2.2-malloc_usable_size.patch
new file mode 100644
index 0000000..2bf8d80
--- /dev/null
+++ b/ElectricFence-2.2.2-malloc_usable_size.patch
@@ -0,0 +1,47 @@
+diff -up ElectricFence-2.2.2/efence.c\~ ElectricFence-2.2.2/efence.c
+--- ElectricFence-2.2.2/efence.c~	2012-03-12 22:48:22.634989256 +0100
++++ ElectricFence-2.2.2/efence.c	2012-03-12 23:05:00.545522379 +0100
+@@ -865,6 +865,41 @@ free(void * address)
+ 	release();
+ }
+ 
++extern C_LINKAGE size_t
++malloc_usable_size(void * address)
++{
++	Slot *	slot;
++
++	lock();
++
++	if ( !noAllocationListProtection )
++		Page_AllowAccess(allocationList, allocationListSize);
++
++	slot = slotForUserAddress(address);
++
++	if ( !slot )
++		EF_Abort("free(%a): address not from malloc().", address);
++
++	if ( slot->mode != ALLOCATED ) {
++		if ( internalUse && slot->mode == INTERNAL_USE )
++			/* Do nothing. */;
++		else {
++			EF_Abort(
++			 "free(%a): malloc_usable_size on freed block."
++			,address);
++		}
++	}
++
++	size_t ret = slot->userSize;
++
++	if ( !noAllocationListProtection )
++		Page_DenyAccess(allocationList, allocationListSize);
++
++	release();
++
++	return ret;
++}
++
+ extern C_LINKAGE void *
+ realloc(void * oldBuffer, size_t newSize)
+ {
+
+Diff finished.  Mon Mar 12 23:06:53 2012
diff --git a/ElectricFence.spec b/ElectricFence.spec
index 4955777..71777fa 100644
--- a/ElectricFence.spec
+++ b/ElectricFence.spec
@@ -1,7 +1,7 @@
 Summary: A debugger which detects memory allocation violations
 Name: ElectricFence
 Version: 2.2.2
-Release: 33%{?dist}
+Release: 34%{?dist}
 License: GPLv2
 Group: Development/Tools
 URL: http://perens.com/FreeSoftware/ElectricFence/
@@ -19,6 +19,7 @@ Patch7: ElectricFence-2.2.2-ef.patch
 Patch8: ElectricFence-2.2.2-builtins.patch
 Patch9: ElectricFence-2.2.2-sse.patch
 Patch10: ElectricFence-2.2.2-posix_memalign.patch
+Patch11: ElectricFence-2.2.2-malloc_usable_size.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 %description
@@ -45,6 +46,7 @@ violations.
 %patch8 -p1
 %patch9 -p1
 %patch10 -p1
+%patch11 -p1
 
 %build
 make CFLAGS='${RPM_OPT_FLAGS} -DUSE_SEMAPHORE -fpic'
@@ -77,6 +79,10 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/*/*
 
 %changelog
+* Mon Mar 12 2012 Petr Machata <pmachata at redhat.com> - 2.2.2-34
+- Add a patch that implements malloc_usable_size
+- Resolves: #772306
+
 * Thu Jan 12 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.2.2-33
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
 


More information about the scm-commits mailing list