From 80218fa109e5f1726737a603eecfd1cb7f233b8b Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Tue, 12 May 2020 16:43:59 +0200 Subject: [PATCH] Fix array overflow on invalid macro arg evaluation `macro_GetArg` had not been changed after the previous commit; however, the old code relied on the `macroArgs->args` array being at least `MAXMACROARGS` entries large (which was the case until the last commit). The boundary against which it checked would have better been written as `sizeof(macroArgs->args)/sizeof(macroArgs->args[0])`, I guess, but what's done is done. --- src/asm/macro.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/asm/macro.c b/src/asm/macro.c index bec91982..b1998625 100644 --- a/src/asm/macro.c +++ b/src/asm/macro.c @@ -64,7 +64,8 @@ char const *macro_GetArg(uint32_t i) { uint32_t realIndex = i + macroArgs->shift - 1; - return realIndex >= MAXMACROARGS ? NULL : macroArgs->args[realIndex]; + return realIndex >= macroArgs->nbArgs ? NULL + : macroArgs->args[realIndex]; } uint32_t macro_GetUniqueID(void)