mirror of
https://github.com/apple/swift-system
synced 2026-11-22 04:30:46 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c6ad0fc39 | ||
|
|
13851a3421 | ||
|
|
8f8d80a4fe | ||
|
|
608a75b962 | ||
|
|
0dbbab4aa1 | ||
|
|
2eb655e0b7 | ||
|
|
07a3f090d7 | ||
|
|
dda2b535b7 | ||
|
|
9ddc89964b | ||
|
|
18a52c4729 | ||
|
|
1c1ad1d3f4 | ||
|
|
395a77f0aa | ||
|
|
b1618475cc | ||
|
|
890830fff1 | ||
|
|
a5f13c77b8 |
No files matched your search
@@ -1,5 +1,8 @@
|
||||
name: Pull request
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
@@ -9,16 +12,50 @@ jobs:
|
||||
name: Test
|
||||
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
|
||||
with:
|
||||
linux_os_versions: '["jammy", "focal"]'
|
||||
enable_macos_checks: true
|
||||
# FIXME: https://github.com/swiftlang/github-workflows/pull/140
|
||||
# Xcode 16.0 and 16.1 are not actually available
|
||||
macos_exclude_xcode_versions: |
|
||||
[
|
||||
{"xcode_version": "16.0"},
|
||||
{"xcode_version": "16.1"},
|
||||
]
|
||||
swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI"
|
||||
enable_linux_checks: true
|
||||
linux_os_versions: '["noble", "jammy", "focal"]'
|
||||
linux_exclude_swift_versions: |
|
||||
[
|
||||
{"os_version": "noble", "swift_version": "5.9"},
|
||||
{"os_version": "noble", "swift_version": "5.10"},
|
||||
{"os_version": "focal", "swift_version": "nightly-6.2"},
|
||||
{"os_version": "focal", "swift_version": "6.2"},
|
||||
{"os_version": "focal", "swift_version": "nightly-6.3"},
|
||||
{"os_version": "focal", "swift_version": "6.3"},
|
||||
{"os_version": "focal", "swift_version": "nightly-main"},
|
||||
]
|
||||
enable_macos_checks: true
|
||||
macos_exclude_xcode_versions: '[]'
|
||||
enable_windows_checks: true
|
||||
windows_exclude_swift_versions: |
|
||||
[
|
||||
{"swift_version": "5.9"},
|
||||
{"swift_version": "5.10"}
|
||||
]
|
||||
enable_linux_static_sdk_build: true
|
||||
linux_static_sdk_exclude_swift_versions: |
|
||||
[
|
||||
{"os_version": "focal", "swift_version": "nightly-6.2"},
|
||||
{"os_version": "focal", "swift_version": "6.2"},
|
||||
{"os_version": "focal", "swift_version": "nightly-6.3"},
|
||||
{"os_version": "focal", "swift_version": "6.3"},
|
||||
{"os_version": "focal", "swift_version": "nightly-main"},
|
||||
]
|
||||
enable_wasm_sdk_build: true
|
||||
wasm_exclude_swift_versions: |
|
||||
[
|
||||
{"os_version": "focal", "swift_version": "nightly-6.2"},
|
||||
{"os_version": "focal", "swift_version": "6.2"},
|
||||
{"os_version": "focal", "swift_version": "nightly-6.3"},
|
||||
{"os_version": "focal", "swift_version": "6.3"},
|
||||
{"os_version": "focal", "swift_version": "nightly-main"},
|
||||
]
|
||||
enable_android_sdk_build: true
|
||||
android_exclude_swift_versions: |
|
||||
[
|
||||
{"os_version": "focal", "swift_version": "nightly-main"},
|
||||
]
|
||||
|
||||
build-abi-stable:
|
||||
name: Build ABI Stable
|
||||
@@ -29,13 +66,7 @@ jobs:
|
||||
enable_windows_checks: false
|
||||
# Only build
|
||||
macos_build_command: "xcrun swift build --build-tests"
|
||||
# FIXME: https://github.com/swiftlang/github-workflows/pull/140
|
||||
# Xcode 16.0 and 16.1 are not actually available
|
||||
macos_exclude_xcode_versions: |
|
||||
[
|
||||
{"xcode_version": "16.0"},
|
||||
{"xcode_version": "16.1"},
|
||||
]
|
||||
macos_exclude_xcode_versions: '[]'
|
||||
# Enable availability to match ABI stable verion of system.
|
||||
swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI -Xbuild-tools-swiftc -DSYSTEM_ABI_STABLE"
|
||||
|
||||
|
||||
@@ -134,11 +134,13 @@ typedef struct __SWIFT_IORING_SQE_FALLBACK_STRUCT swift_io_uring_sqe;
|
||||
#define IORING_FEAT_RW_ATTR (1U << 16)
|
||||
#define IORING_FEAT_NO_IOWAIT (1U << 17)
|
||||
|
||||
#if !defined(_ASM_GENERIC_INT_LL64_H) && !defined(_ASM_GENERIC_INT_L64_H) && !defined(_UAPI_ASM_GENERIC_INT_LL64_H) && !defined(_UAPI_ASM_GENERIC_INT_L64_H)
|
||||
typedef uint8_t __u8;
|
||||
typedef uint16_t __u16;
|
||||
typedef uint32_t __u32;
|
||||
typedef uint64_t __u64;
|
||||
typedef int32_t __s32;
|
||||
#endif
|
||||
|
||||
#ifndef __kernel_rwf_t
|
||||
typedef int __kernel_rwf_t;
|
||||
|
||||
@@ -160,7 +160,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
|
||||
/// No child processes.
|
||||
///
|
||||
/// A `wait(2)` or `waitpid(2)` function was executed
|
||||
/// by a process that dosn't have any existing child processes
|
||||
/// by a process that doesn't have any existing child processes
|
||||
/// or whose child processes are all already being waited for.
|
||||
///
|
||||
/// The corresponding C error is `ECHILD`.
|
||||
|
||||
@@ -517,7 +517,7 @@ fileprivate func HRESULT_CODE(_ hr: HRESULT) -> DWORD {
|
||||
|
||||
@inline(__always)
|
||||
fileprivate func HRESULT_FACILITY(_ hr: HRESULT) -> DWORD {
|
||||
DWORD(hr << 16) & 0x1fff
|
||||
DWORD(hr >> 16) & 0x1fff
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
|
||||
@@ -135,7 +135,11 @@ internal func dup(_ fd: Int32) -> Int32 {
|
||||
|
||||
@inline(__always)
|
||||
internal func dup2(_ fd: Int32, _ fd2: Int32) -> Int32 {
|
||||
_dup2(fd, fd2)
|
||||
// _dup2 returns 0 to indicate success.
|
||||
if _dup2(fd, fd2) == 0 {
|
||||
return fd2
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
@inline(__always)
|
||||
@@ -145,6 +149,12 @@ internal func pread(
|
||||
let handle: intptr_t = _get_osfhandle(fd)
|
||||
if handle == /* INVALID_HANDLE_VALUE */ -1 { ucrt._set_errno(EBADF); return -1 }
|
||||
|
||||
// Windows ReadFile accepts DWORD (32-bit) for buffer size, so validate nbyte doesn't exceed it
|
||||
if nbyte > Int(DWORD.max) {
|
||||
ucrt._set_errno(EINVAL)
|
||||
return -1
|
||||
}
|
||||
|
||||
// NOTE: this is a non-owning handle, do *not* call CloseHandle on it
|
||||
let hFile: HANDLE = HANDLE(bitPattern: handle)!
|
||||
|
||||
@@ -167,6 +177,12 @@ internal func pwrite(
|
||||
let handle: intptr_t = _get_osfhandle(fd)
|
||||
if handle == /* INVALID_HANDLE_VALUE */ -1 { ucrt._set_errno(EBADF); return -1 }
|
||||
|
||||
// Windows WriteFile accepts DWORD (32-bit) for buffer size, so validate nbyte doesn't exceed it
|
||||
if nbyte > Int(DWORD.max) {
|
||||
ucrt._set_errno(EINVAL)
|
||||
return -1
|
||||
}
|
||||
|
||||
// NOTE: this is a non-owning handle, do *not* call CloseHandle on it
|
||||
let hFile: HANDLE = HANDLE(bitPattern: handle)!
|
||||
|
||||
|
||||
@@ -242,6 +242,53 @@ final class FileOperationsTestWindows: XCTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Test that buffer sizes exceeding DWORD.max (4GB) are properly rejected
|
||||
func testBufferSizeLimit() throws {
|
||||
try withTemporaryFilePath(basename: "testBufferSizeLimit") { path in
|
||||
let fd = try FileDescriptor.open(
|
||||
path.appending("test.txt"),
|
||||
.readWrite,
|
||||
options: [.create, .truncate],
|
||||
permissions: .ownerReadWrite
|
||||
)
|
||||
defer { try? fd.close() }
|
||||
|
||||
// Write some data first
|
||||
try fd.writeAll("test data".utf8)
|
||||
|
||||
// Allocate a small buffer for testing
|
||||
let buffer = UnsafeMutableRawBufferPointer.allocate(byteCount: 1024, alignment: 1)
|
||||
defer { buffer.deallocate() }
|
||||
|
||||
// Test that a count exceeding DWORD.max (UInt32.max = 4,294,967,295) returns EINVAL
|
||||
// We use a buffer pointer but pass a count > DWORD.max
|
||||
let oversizedCount = Int(DWORD.max) + 1
|
||||
let oversizedBuffer = UnsafeMutableRawBufferPointer(
|
||||
start: buffer.baseAddress,
|
||||
count: oversizedCount
|
||||
)
|
||||
|
||||
// pread should fail with EINVAL
|
||||
do {
|
||||
_ = try fd.read(fromAbsoluteOffset: 0, into: oversizedBuffer)
|
||||
XCTFail("Expected EINVAL for buffer size exceeding DWORD.max")
|
||||
} catch let err as Errno {
|
||||
XCTAssertEqual(err, .invalidArgument, "Expected EINVAL, got \(err)")
|
||||
}
|
||||
|
||||
// pwrite should also fail with EINVAL
|
||||
do {
|
||||
_ = try fd.write(toAbsoluteOffset: 0, UnsafeRawBufferPointer(oversizedBuffer))
|
||||
XCTFail("Expected EINVAL for buffer size exceeding DWORD.max")
|
||||
} catch let err as Errno {
|
||||
XCTAssertEqual(err, .invalidArgument, "Expected EINVAL, got \(err)")
|
||||
}
|
||||
|
||||
// Verify that exactly DWORD.max works (if we had a buffer that large)
|
||||
// We can't easily test this without allocating 4GB, but the boundary is correct
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // os(Windows)
|
||||
Reference in new issue
Block a user