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
735 /* idx=0: r10, idx=1: r11 */735 /* idx=0: r10, idx=1: r11 */
736 return idx + 10;736 return idx + 10;
737 else737 else
738 return arg_regs[idx];738 return idx >= 0 && idx < REGN ? arg_regs[idx] : 0;
739}739}
740 740
741/* Generate function call. The function address is pushed first, then741/* Generate function call. The function address is pushed first, then
@@ -1221,7 +1221,7 @@ static int arg_prepare_reg(int idx) { · 479 unmodified lines
1221 /* idx=2: r10, idx=3: r11 */1221 /* idx=2: r10, idx=3: r11 */
1222 return idx + 8;1222 return idx + 8;
1223 else1223 else
1224 return arg_regs[idx];1224 return idx >= 0 && idx < REGN ? arg_regs[idx] : 0;
1225}1225}
1226 1226
1227/* Generate function call. The function address is pushed first, then1227/* 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