From 9a5aa1d42bff393b18b6777f381b16f9112f50ad Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 24 Jan 2021 11:26:43 +0100 Subject: [PATCH] Using static asan --- CMakeLists.txt | 2 +- server/main.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a53bc71..4762efe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ set(TEASPEAK_SERVER ON) #set(MEMORY_DEBUG_FLAGS " -fsanitize=leak -fsanitize=address -fstack-protector-all ") #set(MEMORY_DEBUG_FLAGS "-fsanitize=address -fstack-protector-all") #set(MEMORY_DEBUG_FLAGS "-fstack-protector-all") -set(MEMORY_DEBUG_FLAGS " -fsanitize=address ") +set(MEMORY_DEBUG_FLAGS " -fsanitize=address -static-libasan") if (NOT BUILD_OS_ARCH) set(BUILD_OS_ARCH $ENV{build_os_arch}) diff --git a/server/main.cpp b/server/main.cpp index f7da2c7..c9c822d 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -299,9 +299,17 @@ int main(int argc, char** argv) { } /* { - void* ptr = malloc(1234); - free(ptr); - free(ptr); + auto a = malloc(10); // 0xa04010 + auto b = malloc(10); // 0xa04030 + auto c = malloc(10); // 0xa04050 + + free(a); + free(b); // To bypass "double free or corruption (fasttop)" check + free(a); // Double Free !! + + auto d = malloc(10); // 0xa04010 + auto e = malloc(10); // 0xa04030 + auto f = malloc(10); // 0xa04010 - Same as 'd' ! } */ /*