From 7aca274789415e2adbdd23f6877c128298a56eb2 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 13 Dec 2020 12:31:42 +0000 Subject: [PATCH] sclog: log the size of allocated memory regions. This occurred to me recently as a (very small) hole in the logging strategy: if the size of an allocated memory block depended on some secret data, it certainly would change the control flow and memory access pattern inside malloc, but since we disable logging inside malloc, the log file from this test suite would never see the difference. Easily fixed by printing the size of each block in the code that intercepts malloc and realloc. As expected, no test actually fails as a result of filling in this gap. --- test/sclog/sclog.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/sclog/sclog.c b/test/sclog/sclog.c index a964960a..20c1e441 100644 --- a/test/sclog/sclog.c +++ b/test/sclog/sclog.c @@ -212,6 +212,7 @@ static void wrap_malloc_pre(void *wrapctx, void **user_data) { logging_paused++; *user_data = drwrap_get_arg(wrapctx, 0); + dr_fprintf(outfile, "malloc %"PRIuMAX"\n", (uintmax_t)*user_data); } static void wrap_free_pre(void *wrapctx, void **user_data) { @@ -225,6 +226,7 @@ static void wrap_realloc_pre(void *wrapctx, void **user_data) void *ptr = drwrap_get_arg(wrapctx, 0); freed(ptr); *user_data = drwrap_get_arg(wrapctx, 1); + dr_fprintf(outfile, "realloc %"PRIuMAX"\n", (uintmax_t)*user_data); } static void wrap_alloc_post(void *wrapctx, void *user_data) {