about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2024-10-07 10:00:04 +0200
committerGitHub <noreply@github.com>2024-10-07 10:00:04 +0200
commit31ed850c4bc9ed742b43ae8ae81c537f1a4e7433 (patch)
tree14339b598af5e81abe666ac216741a2ca29e7e1c
parent146e535f7b644a3d38f8e90c415974b23ff295c0 (diff)
parent994ac558787cc10512854b85115e7f5e5e268513 (diff)
downloadafl++-31ed850c4bc9ed742b43ae8ae81c537f1a4e7433.tar.gz
Merge pull request #2218 from ea/stable
Fix uninitialized alloc_canary in libdislocator
-rw-r--r--utils/libdislocator/libdislocator.so.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/utils/libdislocator/libdislocator.so.c b/utils/libdislocator/libdislocator.so.c
index b80be1a1..f41491b1 100644
--- a/utils/libdislocator/libdislocator.so.c
+++ b/utils/libdislocator/libdislocator.so.c
@@ -162,7 +162,7 @@ static u8     alloc_verbose,            /* Additional debug messages        */
 static _Atomic size_t total_mem;        /* Currently allocated mem          */
 
 static __thread u32 call_depth;         /* To avoid recursion via fprintf() */
-static u32          alloc_canary;
+static u32          alloc_canary = ALLOC_CANARY;
 
 /* This is the main alloc function. It allocates one page more than necessary,
    sets that tailing page to PROT_NONE, and then increments the return address
@@ -578,6 +578,13 @@ __attribute__((constructor)) void __dislocator_init(void) {
 
 }
 
+__attribute__((destructor)) void __dislocator_fini(void) {
+
+  alloc_canary = ALLOC_CANARY; // restore to default canary value
+
+}
+
+   
 /* NetBSD fault handler specific api subset */
 
 void (*esetfunc(void (*fn)(int, const char *, ...)))(int, const char *, ...) {