aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorahze <ahze@FreeBSD.org>2008-11-24 11:32:46 +0800
committerahze <ahze@FreeBSD.org>2008-11-24 11:32:46 +0800
commitbae8fc35c75146063102a4c36e504d3e983550bd (patch)
tree92839d953d3ecb045f749ac62be0a82c7a9bef9c
parent47091aaf90e184e3d6e6b77b2f5fe8264c893a28 (diff)
downloadfreebsd-ports-gnome-bae8fc35c75146063102a4c36e504d3e983550bd.tar.gz
freebsd-ports-gnome-bae8fc35c75146063102a4c36e504d3e983550bd.tar.zst
freebsd-ports-gnome-bae8fc35c75146063102a4c36e504d3e983550bd.zip
Fix a bug in x_realloc() which tries to read out too many bytes from the old storage after allocating new storage.
PR: ports/127639 Submitted by: Thorsten Glaser <tg@mirbsd.de> (MirBSD project) Reported by: Mel <mel.xyzzy@rachie.is-a-geek.net>
-rw-r--r--devel/ccache/Makefile2
-rw-r--r--devel/ccache/files/patch-util.c25
2 files changed, 26 insertions, 1 deletions
diff --git a/devel/ccache/Makefile b/devel/ccache/Makefile
index 946f08698dfd..da5d96adcef2 100644
--- a/devel/ccache/Makefile
+++ b/devel/ccache/Makefile
@@ -7,7 +7,7 @@
PORTNAME= ccache
PORTVERSION= 2.4
-PORTREVISION= 7
+PORTREVISION= 8
CATEGORIES= devel
MASTER_SITES= http://samba.org/ftp/ccache/
diff --git a/devel/ccache/files/patch-util.c b/devel/ccache/files/patch-util.c
new file mode 100644
index 000000000000..58b76d94f35c
--- /dev/null
+++ b/devel/ccache/files/patch-util.c
@@ -0,0 +1,25 @@
+$MirOS: ports/devel/ccache/patches/patch-util_c,v 1.1 2008/10/05 17:03:37 tg Exp $
+
+ Very interesting bug: tries to read “size” bytes
+ from “ptr” (of size “oldsize”) while copying to
+ “p2” (of size “size”), instead of “oldsize” bytes;
+ with mmap malloc, jemalloc, and possibly omalloc,
+ the additional RAM needed is not always in core…
+
+--- util.c.orig Mon Sep 13 10:38:08 2004
++++ util.c Sun Oct 5 16:58:39 2008
+@@ -187,13 +187,9 @@ void *x_realloc(void *ptr, size_t size)
+ {
+ void *p2;
+ if (!ptr) return x_malloc(size);
+- p2 = malloc(size);
++ p2 = realloc(ptr, size);
+ if (!p2) {
+ fatal("out of memory in x_realloc");
+- }
+- if (ptr) {
+- memcpy(p2, ptr, size);
+- free(ptr);
+ }
+ return p2;
+ }