From: Tobias Brunner Date: Tue, 11 Jun 2013 13:38:56 +0000 (+0200) Subject: leak-detective: Resolve hooked functions during initialization X-Git-Tag: 5.1.0dr1~126 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f5f7053bcdb5b25b412a87f5853b4a6d94b8abe8;p=thirdparty%2Fstrongswan.git leak-detective: Resolve hooked functions during initialization If uses of dlopen(), e.g. when loading plugins, produce errors an error string could get allocated dynamically. At this point realloc() might not yet be resolved and when dlsym() is later called by leak detective to do so the error string might get freed while leak detective is disabled and real_free() will be called with a pointer into one of leak detective's memory blocks instead of a pointer to the block itself, causing a SIGSEGV. --- diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c index 9d9062203d..a245163527 100644 --- a/src/libstrongswan/utils/leak_detective.c +++ b/src/libstrongswan/utils/leak_detective.c @@ -404,10 +404,13 @@ static void* real_realloc(void *ptr, size_t size) #define HOOK(ret, name, ...) ret name(__VA_ARGS__) /** - * Hook initialization when not using hooks + * Hook initialization when not using hooks, resolve functions. */ static bool register_hooks() { + void *buf = real_malloc(8); + real_realloc(buf, 16); + real_free(buf); return TRUE; }