Skip to content

Commit b966e1e

Browse files
committed
Fix OOB shifts in fd_vm_interp_core (#3872)
1 parent 80dd2cf commit b966e1e

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
@@ -969,7 +969,7 @@
969969
/* 0xc0 - 0xcf ******************************************************/
970970

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

975975
FD_VM_INTERP_BRANCH_BEGIN(0xc5) /* FD_SBPF_OP_JSLT_IMM */ /* FIXME: CHECK IMM SIGN EXTENSION */
@@ -982,11 +982,11 @@
982982
FD_VM_INTERP_INSTR_END;
983983

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

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

992992
FD_VM_INTERP_BRANCH_BEGIN(0xcd) /* FD_SBPF_OP_JSLT_REG */
@@ -1000,7 +1000,7 @@
10001000
FD_VM_INTERP_INSTR_END;
10011001

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

10061006
/* 0xd0 - 0xdf ******************************************************/

0 commit comments

Comments
 (0)