Skip to content

Commit b584504

Browse files
committed
fix off-by-one in IORequest.openat
1 parent d099546 commit b584504

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/System/IORequest.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ extension IORequest {
4646
request.rawValue.addr = unsafeBitCast(path, to: UInt64.self)
4747
request.rawValue.open_flags = UInt32(bitPattern: options.rawValue | mode.rawValue)
4848
request.rawValue.len = permissions?.rawValue ?? 0
49-
request.rawValue.file_index = UInt32(slot?.index ?? 0)
49+
if let fileSlot = slot {
50+
request.rawValue.file_index = UInt32(fileSlot.index + 1)
51+
}
5052
case .read(let file, let buffer, let offset), .write(let file, let buffer, let offset):
5153
if case .read = self {
5254
if case .registered = buffer {

0 commit comments

Comments
 (0)