Skip to content

Commit 87130d1

Browse files
committed
Fix OOB shifts in fd_vm_interp_core (#3872)
1 parent 1322ba5 commit 87130d1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/flamenco/vm/fd_vm_interp_core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@
976976
/* 0xc0 - 0xcf ******************************************************/
977977

978978
FD_VM_INTERP_INSTR_BEGIN(0xc4) /* FD_SBPF_OP_ARSH_IMM */
979-
reg[ dst ] = (ulong)(uint)( (int)reg_dst >> imm ); /* FIXME: WIDE SHIFTS, STRICT SIGN EXTENSION */
979+
reg[ dst ] = (ulong)(uint)fd_int_shift_right( (int)reg_dst, (int)imm );
980980
FD_VM_INTERP_INSTR_END;
981981

982982
FD_VM_INTERP_BRANCH_BEGIN(0xc5) /* FD_SBPF_OP_JSLT_IMM */ /* FIXME: CHECK IMM SIGN EXTENSION */
@@ -989,11 +989,11 @@
989989
FD_VM_INTERP_INSTR_END;
990990

991991
FD_VM_INTERP_INSTR_BEGIN(0xc7) /* FD_SBPF_OP_ARSH64_IMM */
992-
reg[ dst ] = (ulong)( (long)reg_dst >> imm ); /* FIXME: WIDE SHIFTS, STRICT SIGN EXTENSION */
992+
reg[ dst ] = (ulong)fd_long_shift_right( (long)reg_dst, (int)imm );
993993
FD_VM_INTERP_INSTR_END;
994994

995995
FD_VM_INTERP_INSTR_BEGIN(0xcc) /* FD_SBPF_OP_ARSH_REG */
996-
reg[ dst ] = (ulong)(uint)( (int)reg_dst >> (uint)reg_src ); /* FIXME: WIDE SHIFTS, STRICT SIGN EXTENSION */
996+
reg[ dst ] = (ulong)(uint)fd_int_shift_right( (int)reg_dst, (int)reg_src );
997997
FD_VM_INTERP_INSTR_END;
998998

999999
FD_VM_INTERP_BRANCH_BEGIN(0xcd) /* FD_SBPF_OP_JSLT_REG */
@@ -1007,7 +1007,7 @@
10071007
FD_VM_INTERP_INSTR_END;
10081008

10091009
FD_VM_INTERP_INSTR_BEGIN(0xcf) /* FD_SBPF_OP_ARSH64_REG */
1010-
reg[ dst ] = (ulong)( (long)reg_dst >> reg_src ); /* FIXME: WIDE SHIFTS, STRICT SIGN EXTENSION */
1010+
reg[ dst ] = (ulong)fd_long_shift_right( (long)reg_dst, (int)reg_src );
10111011
FD_VM_INTERP_INSTR_END;
10121012

10131013
/* 0xd0 - 0xdf ******************************************************/

0 commit comments

Comments
 (0)