bpf: use bitCast instead of intCast in ld_imm_impl
Any 32 bit immediate is allowed in a BPF instruction, including those greater than the largest positive i32 value.
This commit is contained in:
committed by
Alex Rønne Petersen
parent
4cfb58342a
commit
05b7ca6356
@@ -642,7 +642,7 @@ pub const Insn = packed struct {
|
||||
.dst = @intFromEnum(dst),
|
||||
.src = @intFromEnum(src),
|
||||
.off = 0,
|
||||
.imm = @as(i32, @intCast(@as(u32, @truncate(imm)))),
|
||||
.imm = @as(i32, @bitCast(@as(u32, @truncate(imm)))),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ pub const Insn = packed struct {
|
||||
.dst = 0,
|
||||
.src = 0,
|
||||
.off = 0,
|
||||
.imm = @as(i32, @intCast(@as(u32, @truncate(imm >> 32)))),
|
||||
.imm = @as(i32, @bitCast(@as(u32, @truncate(imm >> 32)))),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user