From fb5eaa12468af363a1c21c347ae16b69a7e80406 Mon Sep 17 00:00:00 2001 From: Michael Stadelmann-Steinert <206414085+MSSonline@users.noreply.github.com> Date: Mon, 3 Aug 2026 20:28:26 +0200 Subject: [PATCH 1/2] Update create.c correct readableSectorTags allocation size to prevent heap overflow --- src/create.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/create.c b/src/create.c index 9675187..16bd51d 100644 --- a/src/create.c +++ b/src/create.c @@ -361,7 +361,7 @@ AARU_EXPORT void *AARU_CALL aaruf_create(const char *filepath, const uint32_t me TRACE("Generating random GUID"); generate_random_bytes(ctx->header.guid, GUID_SIZE); - ctx->readableSectorTags = (bool *)malloc(sizeof(bool) * MaxSectorTag); + ctx->readableSectorTags = (bool *)malloc(sizeof(bool) * (MaxSectorTag + 1)); if(ctx->readableSectorTags == NULL) { @@ -371,7 +371,7 @@ AARU_EXPORT void *AARU_CALL aaruf_create(const char *filepath, const uint32_t me return NULL; } - memset(ctx->readableSectorTags, 0, sizeof(bool) * MaxSectorTag); + memset(ctx->readableSectorTags, 0, sizeof(bool) * (MaxSectorTag + 1)); // Initialize image info TRACE("Initializing image info"); From 3e85911a0bf78e2b7b18f6e355da5ba717b0ad39 Mon Sep 17 00:00:00 2001 From: Michael Stadelmann-Steinert <206414085+MSSonline@users.noreply.github.com> Date: Mon, 3 Aug 2026 20:31:03 +0200 Subject: [PATCH 2/2] Update open.c correct readableSectorTags allocation size to prevent heap overflow --- src/open.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/open.c b/src/open.c index 2554f4e..2f00693 100644 --- a/src/open.c +++ b/src/open.c @@ -430,7 +430,7 @@ AARU_EXPORT void *AARU_CALL aaruf_open(const char *filepath, const bool resume_m TRACE("Opening image version %d.%d", ctx->header.imageMajorVersion, ctx->header.imageMinorVersion); TRACE("Allocating memory for readable sector tags bitmap"); - ctx->readableSectorTags = (bool *)malloc(sizeof(bool) * MaxSectorTag); + ctx->readableSectorTags = (bool *)malloc(sizeof(bool) * (MaxSectorTag + 1)); if(ctx->readableSectorTags == NULL) { @@ -442,7 +442,7 @@ AARU_EXPORT void *AARU_CALL aaruf_open(const char *filepath, const bool resume_m return NULL; } - memset(ctx->readableSectorTags, 0, sizeof(bool) * MaxSectorTag); + memset(ctx->readableSectorTags, 0, sizeof(bool) * (MaxSectorTag + 1)); TRACE("Setting up image info");