From 63f86be18d5e3fe45b1d991681cd638cd4ff2565 Mon Sep 17 00:00:00 2001 From: Jack May Date: Mon, 16 Nov 2020 17:18:50 -0800 Subject: [PATCH] Fix negate with overflow (#117) --- src/vm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vm.rs b/src/vm.rs index ca52593a..66b2a1c2 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -618,7 +618,7 @@ impl<'a, E: UserDefinedError> EbpfVm<'a, E> { } reg[dst] >>= reg[src] }, - ebpf::NEG64 => reg[dst] = -(reg[dst] as i64) as u64, + ebpf::NEG64 => reg[dst] = (reg[dst] as i64).wrapping_neg() as u64, ebpf::MOD64_IMM => reg[dst] %= insn.imm as u64, ebpf::MOD64_REG => { if reg[src] == 0 {