Skip to content

Commit

Permalink
fix integer overflow in IoUring buffer ring size calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
karlbohlmark authored and andrewrk committed May 9, 2024
1 parent d4d1efe commit 6eb17a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/std/os/linux/IoUring.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ pub fn setup_buf_ring(fd: posix.fd_t, entries: u16, group_id: u16) !*align(mem.p
if (entries == 0 or entries > 1 << 15) return error.EntriesNotInRange;
if (!std.math.isPowerOfTwo(entries)) return error.EntriesNotPowerOfTwo;

const mmap_size = entries * @sizeOf(linux.io_uring_buf);
const mmap_size = @as(usize, entries) * @sizeOf(linux.io_uring_buf);
const mmap = try posix.mmap(
null,
mmap_size,
Expand Down

0 comments on commit 6eb17a0

Please sign in to comment.