git.samba.org
/
metze
/
samba
/
wip.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0b2b9fd
)
talloc: change TALLOC_MAGIC for version 2.0.0
author
Stefan Metzmacher
<metze@samba.org>
Thu, 2 Jul 2009 08:48:24 +0000
(10:48 +0200)
committer
Stefan Metzmacher
<metze@samba.org>
Thu, 2 Jul 2009 08:48:24 +0000
(10:48 +0200)
metze
lib/talloc/talloc.c
patch
|
blob
|
history
diff --git
a/lib/talloc/talloc.c
b/lib/talloc/talloc.c
index 33cbfd7d268dc737e95948c44575ac6c53d835d7..c8ecac1619fa423dce8d1a3cf30bb9fe18bf9fb5 100644
(file)
--- a/
lib/talloc/talloc.c
+++ b/
lib/talloc/talloc.c
@@
-57,7
+57,9
@@
#define MAX_TALLOC_SIZE 0x10000000
#define MAX_TALLOC_SIZE 0x10000000
-#define TALLOC_MAGIC 0xe814ec70
+#define TALLOC_MAGIC_V1 0xe814ec70
+#define TALLOC_MAGIC_V2 0xe814ec80
+#define TALLOC_MAGIC TALLOC_MAGIC_V2
#define TALLOC_FLAG_FREE 0x01
#define TALLOC_FLAG_LOOP 0x02
#define TALLOC_FLAG_POOL 0x04 /* This is a talloc pool */
#define TALLOC_FLAG_FREE 0x01
#define TALLOC_FLAG_LOOP 0x02
#define TALLOC_FLAG_POOL 0x04 /* This is a talloc pool */
@@
-154,6
+156,11
@@
static void talloc_abort(const char *reason)
talloc_abort_fn(reason);
}
talloc_abort_fn(reason);
}
+static void talloc_abort_magic_v1(void)
+{
+ talloc_abort("Bad talloc magic value - old magic v1 used");
+}
+
static void talloc_abort_double_free(void)
{
talloc_abort("Bad talloc magic value - double free");
static void talloc_abort_double_free(void)
{
talloc_abort("Bad talloc magic value - double free");
@@
-170,6
+177,10
@@
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 | ~0xF)) != TALLOC_MAGIC)) {
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 | ~0xF)) != TALLOC_MAGIC)) {
+ if ((tc->flags & (~0xF)) == TALLOC_MAGIC_V1)) {
+ talloc_abort_magic_v1();
+ }
+
if (tc->flags & TALLOC_FLAG_FREE) {
talloc_abort_double_free();
} else {
if (tc->flags & TALLOC_FLAG_FREE) {
talloc_abort_double_free();
} else {