From: Andrew Bartlett Date: Mon, 8 Jan 2018 04:29:19 +0000 (+1300) Subject: talloc: Remove talloc_abort_magic() X-Git-Tag: talloc-2.1.11~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=00ee9da50b289a68621f2af755d4283fe6cb3bc7;p=thirdparty%2Fsamba.git talloc: Remove talloc_abort_magic() The check required for talloc_abort_magic() prevents the 'access after free error' from being printed. It is also no longer possible to determine the difference between invalid memory and a talloc version mismatch as the magic is now random on many platforms. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13210 Signed-off-by: Andrew Bartlett Reviewed-by: Gary Lockyer --- diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index 7721fa4a9c6..3569ba75929 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -429,11 +429,6 @@ static void talloc_abort(const char *reason) talloc_abort_fn(reason); } -static void talloc_abort_magic(unsigned magic) -{ - talloc_abort("Bad talloc magic value - wrong talloc version used/mixed"); -} - static void talloc_abort_access_after_free(void) { talloc_abort("Bad talloc magic value - access after free"); @@ -450,19 +445,14 @@ static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr) const char *pp = (const char *)ptr; struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE); if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~TALLOC_FLAG_MASK)) != talloc_magic)) { - if ((tc->flags & (~TALLOC_FLAG_MASK)) == talloc_magic) { - talloc_abort_magic(tc->flags & (~TALLOC_FLAG_MASK)); - return NULL; - } - - if (tc->flags & TALLOC_FLAG_FREE) { - talloc_log("talloc: access after free error - first free may be at %s\n", tc->name); - talloc_abort_access_after_free(); - return NULL; - } else { + if ((tc->flags & (~TALLOC_FLAG_MASK)) != talloc_magic) { talloc_abort_unknown_value(); return NULL; } + + talloc_log("talloc: access after free error - first free may be at %s\n", tc->name); + talloc_abort_access_after_free(); + return NULL; } return tc; }