History

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.

Michael Matz committed 5 years ago

Commit ce8814c1 parent c4ae3261 file · +2 −2Browse files

Unified · Split

x86_64-gen.c+2−2
@@ -735,7 +735,7 @@ static int arg_prepare_reg(int idx) { · 734 unmodified lines
735735 /* idx=0: r10, idx=1: r11 */
736736 return idx + 10;
737737 else
738− return arg_regs[idx];
738+ return idx >= 0 && idx < REGN ? arg_regs[idx] : 0;
739739 }
740740
741741 /* Generate function call. The function address is pushed first, then
@@ -1221,7 +1221,7 @@ static int arg_prepare_reg(int idx) { · 479 unmodified lines
12211221 /* idx=2: r10, idx=3: r11 */
12221222 return idx + 8;
12231223 else
1224− return arg_regs[idx];
1224+ return idx >= 0 && idx < REGN ? arg_regs[idx] : 0;
12251225 }
12261226
12271227 /* Generate function call. The function address is pushed first, then

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t