]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
leak-detective: Resolve hooked functions during initialization
authorTobias Brunner <tobias@strongswan.org>
Tue, 11 Jun 2013 13:38:56 +0000 (15:38 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 11 Jun 2013 13:48:26 +0000 (15:48 +0200)
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.

src/libstrongswan/utils/leak_detective.c

index 9d9062203dcff050634763501d379f32255ba1f6..a245163527ff3ef37f77e68267260635d10a289a 100644 (file)
@@ -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;
 }