Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit 496313a

Browse files
Feyorshalexrp
authored andcommitted
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.
1 parent 8744865 commit 496313a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/std/os/linux/bpf.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ pub const Insn = packed struct {
642642
.dst = @intFromEnum(dst),
643643
.src = @intFromEnum(src),
644644
.off = 0,
645-
.imm = @as(i32, @intCast(@as(u32, @truncate(imm)))),
645+
.imm = @as(i32, @bitCast(@as(u32, @truncate(imm)))),
646646
};
647647
}
648648

@@ -652,7 +652,7 @@ pub const Insn = packed struct {
652652
.dst = 0,
653653
.src = 0,
654654
.off = 0,
655-
.imm = @as(i32, @intCast(@as(u32, @truncate(imm >> 32)))),
655+
.imm = @as(i32, @bitCast(@as(u32, @truncate(imm >> 32)))),
656656
};
657657
}
658658

0 commit comments

Comments
 (0)