Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <05e2d053cdb7c8726eb0f9bcebbbf048@exys.org>
Date: Wed, 12 Oct 2011 16:46:30 +0200
From: aep <aep@...s.org>
To: <musl@...ts.openwall.com>
Subject: Re: [PATCH] properly terminate linked link of dsos

clang optimized away the check in calloc.c to false.
I can work around it with a cast to something volatile:

diff --git a/src/malloc/calloc.c b/src/malloc/calloc.c
index 9d57456..22f2c01 100644
--- a/src/malloc/calloc.c
+++ b/src/malloc/calloc.c
@@ -13,8 +13,10 @@ void *calloc(size_t m, size_t n)
         n *= m;
         p = malloc(n);
         if (!p) return 0;
+
+    volatile long long dont_optimize_me = p;
         /* Only do this for non-mmapped chunks */
-       if (((size_t *)p)[-1] & 7) {
+       if (((size_t *)dont_optimize_me)[-1] & 7) {
                 /* Only write words that are not already zero */
                 m = (n + sizeof *z - 1)/sizeof *z;
                 for (z=p; m; m--, z++) if (*z) *z=0;

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.