From ce8814cdd65612b523dc77814f1999bb26d421f7 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Fri, 12 Feb 2021 23:46:21 +0100 Subject: [PATCH] Avoid array overflow with fuzzed source code we might run into this with idx out of bounds. We're going to error out on this later, but let's not access out-of-bounds elements. --- x86_64-gen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x86_64-gen.c b/x86_64-gen.c index 271f3d23..f8c56348 100644 --- a/x86_64-gen.c +++ b/x86_64-gen.c @@ -735,7 +735,7 @@ static int arg_prepare_reg(int idx) { /* idx=0: r10, idx=1: r11 */ return idx + 10; else - return arg_regs[idx]; + return idx >= 0 && idx < REGN ? arg_regs[idx] : 0; } /* Generate function call. The function address is pushed first, then @@ -1221,7 +1221,7 @@ static int arg_prepare_reg(int idx) { /* idx=2: r10, idx=3: r11 */ return idx + 8; else - return arg_regs[idx]; + return idx >= 0 && idx < REGN ? arg_regs[idx] : 0; } /* Generate function call. The function address is pushed first, then -- 2.11.4.GIT