| author | |
| committer | |
| log | 031044b3994d4510f64bd08ecba0ab01a7ed48c6 |
| tree | 7fa8e0372e2f1cff77ef83ea76441b1c7bad7dd3 |
| parent | f7d47aed47b3fb8f593c398a8e38e66e2d10e1c1 |
12 files changed, 138 insertions(+), 104 deletions(-)
lib/std/Io/IoUring.zig+1-1| ... | ... | @@ -1469,7 +1469,7 @@ fn pwrite(userdata: ?*anyopaque, file: Io.File, buffer: []const u8, offset: std. |
| 1469 | 1469 | .OVERFLOW => return error.Unseekable, |
| 1470 | 1470 | .BUSY => return error.DeviceBusy, |
| 1471 | 1471 | .CONNRESET => return error.ConnectionResetByPeer, |
| 1472 | .MSGSIZE => return error.MessageTooBig, | |
| 1472 | .MSGSIZE => return error.MessageOversize, | |
| 1473 | 1473 | else => |err| return std.posix.unexpectedErrno(err), |
| 1474 | 1474 | } |
| 1475 | 1475 | } |
lib/std/Io/Threaded.zig+50-32| ... | ... | @@ -966,7 +966,7 @@ fn dirStatPathPosix( |
| 966 | 966 | try t.checkCancel(); |
| 967 | 967 | var stat = std.mem.zeroes(posix.Stat); |
| 968 | 968 | switch (posix.errno(fstatat_sym(dir.handle, sub_path_posix, &stat, flags))) { |
| 969 | .SUCCESS => return statFromPosix(stat), | |
| 969 | .SUCCESS => return statFromPosix(&stat), | |
| 970 | 970 | .INTR => continue, |
| 971 | 971 | .INVAL => |err| return errnoBug(err), |
| 972 | 972 | .BADF => |err| return errnoBug(err), // Always a race condition. |
| ... | ... | @@ -1166,8 +1166,9 @@ fn dirCreateFilePosix( |
| 1166 | 1166 | if (has_flock_open_flags and flags.lock_nonblocking) { |
| 1167 | 1167 | var fl_flags: usize = while (true) { |
| 1168 | 1168 | try t.checkCancel(); |
| 1169 | switch (posix.errno(posix.system.fcntl(fd, posix.F.GETFL, 0))) { | |
| 1170 | .SUCCESS => break, | |
| 1169 | const rc = posix.system.fcntl(fd, posix.F.GETFL, @as(usize, 0)); | |
| 1170 | switch (posix.errno(rc)) { | |
| 1171 | .SUCCESS => break @intCast(rc), | |
| 1171 | 1172 | .INTR => continue, |
| 1172 | 1173 | else => |err| return posix.unexpectedErrno(err), |
| 1173 | 1174 | } |
| ... | ... | @@ -1295,8 +1296,9 @@ fn dirOpenFile( |
| 1295 | 1296 | if (has_flock_open_flags and flags.lock_nonblocking) { |
| 1296 | 1297 | var fl_flags: usize = while (true) { |
| 1297 | 1298 | try t.checkCancel(); |
| 1298 | switch (posix.errno(posix.system.fcntl(fd, posix.F.GETFL, 0))) { | |
| 1299 | .SUCCESS => break, | |
| 1299 | const rc = posix.system.fcntl(fd, posix.F.GETFL, @as(usize, 0)); | |
| 1300 | switch (posix.errno(rc)) { | |
| 1301 | .SUCCESS => break @intCast(rc), | |
| 1300 | 1302 | .INTR => continue, |
| 1301 | 1303 | else => |err| return posix.unexpectedErrno(err), |
| 1302 | 1304 | } |
| ... | ... | @@ -1755,7 +1757,7 @@ fn sleepPosix(userdata: ?*anyopaque, timeout: Io.Timeout) Io.SleepError!void { |
| 1755 | 1757 | .sec = std.math.maxInt(sec_type), |
| 1756 | 1758 | .nsec = std.math.maxInt(nsec_type), |
| 1757 | 1759 | }; |
| 1758 | break :t timestampToPosix(d.duration.nanoseconds); | |
| 1760 | break :t timestampToPosix(d.raw.toNanoseconds()); | |
| 1759 | 1761 | }; |
| 1760 | 1762 | while (true) { |
| 1761 | 1763 | try t.checkCancel(); |
| ... | ... | @@ -1850,6 +1852,7 @@ fn netListenUnix( |
| 1850 | 1852 | error.ProtocolUnsupportedBySystem => return error.AddressFamilyUnsupported, |
| 1851 | 1853 | error.ProtocolUnsupportedByAddressFamily => return error.AddressFamilyUnsupported, |
| 1852 | 1854 | error.SocketModeUnsupported => return error.AddressFamilyUnsupported, |
| 1855 | error.OptionUnsupported => return error.Unexpected, | |
| 1853 | 1856 | else => |e| return e, |
| 1854 | 1857 | }; |
| 1855 | 1858 | errdefer posix.close(socket_fd); |
| ... | ... | @@ -2037,7 +2040,10 @@ fn netConnectUnix( |
| 2037 | 2040 | ) net.UnixAddress.ConnectError!net.Socket.Handle { |
| 2038 | 2041 | if (!net.has_unix_sockets) return error.AddressFamilyUnsupported; |
| 2039 | 2042 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2040 | const socket_fd = try openSocketPosix(t, posix.AF.UNIX, .{ .mode = .stream }); | |
| 2043 | const socket_fd = openSocketPosix(t, posix.AF.UNIX, .{ .mode = .stream }) catch |err| switch (err) { | |
| 2044 | error.OptionUnsupported => return error.Unexpected, | |
| 2045 | else => |e| return e, | |
| 2046 | }; | |
| 2041 | 2047 | errdefer posix.close(socket_fd); |
| 2042 | 2048 | var storage: UnixAddress = undefined; |
| 2043 | 2049 | const addr_len = addressUnixToPosix(address, &storage); |
| ... | ... | @@ -2064,7 +2070,22 @@ fn netBindIpPosix( |
| 2064 | 2070 | }; |
| 2065 | 2071 | } |
| 2066 | 2072 | |
| 2067 | fn openSocketPosix(t: *Threaded, family: posix.sa_family_t, options: IpAddress.BindOptions) !posix.socket_t { | |
| 2073 | fn openSocketPosix( | |
| 2074 | t: *Threaded, | |
| 2075 | family: posix.sa_family_t, | |
| 2076 | options: IpAddress.BindOptions, | |
| 2077 | ) error{ | |
| 2078 | AddressFamilyUnsupported, | |
| 2079 | ProtocolUnsupportedBySystem, | |
| 2080 | ProcessFdQuotaExceeded, | |
| 2081 | SystemFdQuotaExceeded, | |
| 2082 | SystemResources, | |
| 2083 | ProtocolUnsupportedByAddressFamily, | |
| 2084 | SocketModeUnsupported, | |
| 2085 | OptionUnsupported, | |
| 2086 | Unexpected, | |
| 2087 | Canceled, | |
| 2088 | }!posix.socket_t { | |
| 2068 | 2089 | const mode = posixSocketMode(options.mode); |
| 2069 | 2090 | const protocol = posixProtocol(options.protocol); |
| 2070 | 2091 | const socket_fd = while (true) { |
| ... | ... | @@ -2209,7 +2230,7 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net. |
| 2209 | 2230 | .NOTCONN => return error.SocketUnconnected, |
| 2210 | 2231 | .CONNRESET => return error.ConnectionResetByPeer, |
| 2211 | 2232 | .TIMEDOUT => return error.Timeout, |
| 2212 | .PIPE => return error.BrokenPipe, | |
| 2233 | .PIPE => return error.SocketUnconnected, | |
| 2213 | 2234 | .NETDOWN => return error.NetworkDown, |
| 2214 | 2235 | else => |err| return posix.unexpectedErrno(err), |
| 2215 | 2236 | } |
| ... | ... | @@ -2253,29 +2274,29 @@ fn netSendOne( |
| 2253 | 2274 | flags: u32, |
| 2254 | 2275 | ) net.Socket.SendError!void { |
| 2255 | 2276 | var addr: PosixAddress = undefined; |
| 2256 | var iovec: posix.iovec = .{ .base = @constCast(message.data_ptr), .len = message.data_len }; | |
| 2257 | const msg: posix.msghdr = .{ | |
| 2277 | var iovec: posix.iovec_const = .{ .base = @constCast(message.data_ptr), .len = message.data_len }; | |
| 2278 | const msg: posix.msghdr_const = .{ | |
| 2258 | 2279 | .name = &addr.any, |
| 2259 | 2280 | .namelen = addressToPosix(message.address, &addr), |
| 2260 | .iov = iovec[0..1], | |
| 2281 | .iov = (&iovec)[0..1], | |
| 2261 | 2282 | .iovlen = 1, |
| 2262 | 2283 | .control = @constCast(message.control.ptr), |
| 2263 | .controllen = message.control.len, | |
| 2284 | .controllen = @intCast(message.control.len), | |
| 2264 | 2285 | .flags = 0, |
| 2265 | 2286 | }; |
| 2266 | 2287 | while (true) { |
| 2267 | 2288 | try t.checkCancel(); |
| 2268 | const rc = posix.system.sendmsg(handle, msg, flags); | |
| 2289 | const rc = posix.system.sendmsg(handle, &msg, flags); | |
| 2269 | 2290 | if (is_windows) { |
| 2270 | 2291 | if (rc == windows.ws2_32.SOCKET_ERROR) { |
| 2271 | 2292 | switch (windows.ws2_32.WSAGetLastError()) { |
| 2272 | 2293 | .WSAEACCES => return error.AccessDenied, |
| 2273 | 2294 | .WSAEADDRNOTAVAIL => return error.AddressNotAvailable, |
| 2274 | 2295 | .WSAECONNRESET => return error.ConnectionResetByPeer, |
| 2275 | .WSAEMSGSIZE => return error.MessageTooBig, | |
| 2296 | .WSAEMSGSIZE => return error.MessageOversize, | |
| 2276 | 2297 | .WSAENOBUFS => return error.SystemResources, |
| 2277 | 2298 | .WSAENOTSOCK => return error.FileDescriptorNotASocket, |
| 2278 | .WSAEAFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 2299 | .WSAEAFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 2279 | 2300 | .WSAEDESTADDRREQ => unreachable, // A destination address is required. |
| 2280 | 2301 | .WSAEFAULT => unreachable, // The lpBuffers, lpTo, lpOverlapped, lpNumberOfBytesSent, or lpCompletionRoutine parameters are not part of the user address space, or the lpTo parameter is too small. |
| 2281 | 2302 | .WSAEHOSTUNREACH => return error.NetworkUnreachable, |
| ... | ... | @@ -2285,7 +2306,6 @@ fn netSendOne( |
| 2285 | 2306 | .WSAENETUNREACH => return error.NetworkUnreachable, |
| 2286 | 2307 | .WSAENOTCONN => return error.SocketUnconnected, |
| 2287 | 2308 | .WSAESHUTDOWN => unreachable, // The socket has been shut down; it is not possible to WSASendTo on a socket after shutdown has been invoked with how set to SD_SEND or SD_BOTH. |
| 2288 | .WSAEWOULDBLOCK => return error.WouldBlock, | |
| 2289 | 2309 | .WSANOTINITIALISED => unreachable, // A successful WSAStartup call must occur before using this function. |
| 2290 | 2310 | else => |err| return windows.unexpectedWSAError(err), |
| 2291 | 2311 | } |
| ... | ... | @@ -2299,28 +2319,24 @@ fn netSendOne( |
| 2299 | 2319 | message.data_len = @intCast(rc); |
| 2300 | 2320 | return; |
| 2301 | 2321 | }, |
| 2322 | .INTR => continue, | |
| 2323 | ||
| 2302 | 2324 | .ACCES => return error.AccessDenied, |
| 2303 | .AGAIN => return error.WouldBlock, | |
| 2304 | 2325 | .ALREADY => return error.FastOpenAlreadyInProgress, |
| 2305 | 2326 | .BADF => |err| return errnoBug(err), |
| 2306 | 2327 | .CONNRESET => return error.ConnectionResetByPeer, |
| 2307 | 2328 | .DESTADDRREQ => |err| return errnoBug(err), |
| 2308 | 2329 | .FAULT => |err| return errnoBug(err), |
| 2309 | .INTR => continue, | |
| 2310 | 2330 | .INVAL => |err| return errnoBug(err), |
| 2311 | 2331 | .ISCONN => |err| return errnoBug(err), |
| 2312 | .MSGSIZE => return error.MessageTooBig, | |
| 2332 | .MSGSIZE => return error.MessageOversize, | |
| 2313 | 2333 | .NOBUFS => return error.SystemResources, |
| 2314 | 2334 | .NOMEM => return error.SystemResources, |
| 2315 | 2335 | .NOTSOCK => |err| return errnoBug(err), |
| 2316 | 2336 | .OPNOTSUPP => |err| return errnoBug(err), |
| 2317 | .PIPE => return error.BrokenPipe, | |
| 2318 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 2319 | .LOOP => return error.SymLinkLoop, | |
| 2320 | .NAMETOOLONG => return error.NameTooLong, | |
| 2321 | .NOENT => return error.FileNotFound, | |
| 2322 | .NOTDIR => return error.NotDir, | |
| 2323 | .HOSTUNREACH => return error.NetworkUnreachable, | |
| 2337 | .PIPE => return error.SocketUnconnected, | |
| 2338 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 2339 | .HOSTUNREACH => return error.HostUnreachable, | |
| 2324 | 2340 | .NETUNREACH => return error.NetworkUnreachable, |
| 2325 | 2341 | .NOTCONN => return error.SocketUnconnected, |
| 2326 | 2342 | .NETDOWN => return error.NetworkDown, |
| ... | ... | @@ -2447,7 +2463,7 @@ fn netReceive( |
| 2447 | 2463 | .iov = (&iov)[0..1], |
| 2448 | 2464 | .iovlen = 1, |
| 2449 | 2465 | .control = message.control.ptr, |
| 2450 | .controllen = message.control.len, | |
| 2466 | .controllen = @intCast(message.control.len), | |
| 2451 | 2467 | .flags = undefined, |
| 2452 | 2468 | }; |
| 2453 | 2469 | |
| ... | ... | @@ -2465,7 +2481,7 @@ fn netReceive( |
| 2465 | 2481 | .trunc = (msg.flags & posix.MSG.TRUNC) != 0, |
| 2466 | 2482 | .ctrunc = (msg.flags & posix.MSG.CTRUNC) != 0, |
| 2467 | 2483 | .oob = (msg.flags & posix.MSG.OOB) != 0, |
| 2468 | .errqueue = (msg.flags & posix.MSG.ERRQUEUE) != 0, | |
| 2484 | .errqueue = if (@hasDecl(posix.MSG, "ERRQUEUE")) (msg.flags & posix.MSG.ERRQUEUE) != 0 else false, | |
| 2469 | 2485 | }, |
| 2470 | 2486 | }; |
| 2471 | 2487 | message_i += 1; |
| ... | ... | @@ -2605,6 +2621,7 @@ fn netInterfaceNameResolve( |
| 2605 | 2621 | error.ProtocolUnsupportedBySystem => return error.Unexpected, |
| 2606 | 2622 | error.ProtocolUnsupportedByAddressFamily => return error.Unexpected, |
| 2607 | 2623 | error.SocketModeUnsupported => return error.Unexpected, |
| 2624 | error.OptionUnsupported => return error.Unexpected, | |
| 2608 | 2625 | else => |e| return e, |
| 2609 | 2626 | }; |
| 2610 | 2627 | defer posix.close(sock_fd); |
| ... | ... | @@ -3079,9 +3096,10 @@ fn lookupDns( |
| 3079 | 3096 | } |
| 3080 | 3097 | } |
| 3081 | 3098 | |
| 3082 | var ip4_mapped: [HostName.ResolvConf.max_nameservers]IpAddress = undefined; | |
| 3099 | var ip4_mapped_buffer: [HostName.ResolvConf.max_nameservers]IpAddress = undefined; | |
| 3100 | const ip4_mapped = ip4_mapped_buffer[0..rc.nameservers_len]; | |
| 3083 | 3101 | var any_ip6 = false; |
| 3084 | for (rc.nameservers(), &ip4_mapped) |*ns, *m| { | |
| 3102 | for (rc.nameservers(), ip4_mapped) |*ns, *m| { | |
| 3085 | 3103 | m.* = .{ .ip6 = .fromAny(ns.*) }; |
| 3086 | 3104 | any_ip6 = any_ip6 or ns.* == .ip6; |
| 3087 | 3105 | } |
| ... | ... | @@ -3101,7 +3119,7 @@ fn lookupDns( |
| 3101 | 3119 | }; |
| 3102 | 3120 | defer socket.close(t_io); |
| 3103 | 3121 | |
| 3104 | const mapped_nameservers = if (any_ip6) ip4_mapped[0..rc.nameservers_len] else rc.nameservers(); | |
| 3122 | const mapped_nameservers = if (any_ip6) ip4_mapped else rc.nameservers(); | |
| 3105 | 3123 | const queries = queries_buffer[0..nq]; |
| 3106 | 3124 | const answers = answers_buffer[0..queries.len]; |
| 3107 | 3125 | var answers_remaining = answers.len; |
lib/std/Io/net.zig+7-2| ... | ... | @@ -209,6 +209,9 @@ pub const IpAddress = union(enum) { |
| 209 | 209 | ProtocolUnsupportedBySystem, |
| 210 | 210 | ProtocolUnsupportedByAddressFamily, |
| 211 | 211 | SocketModeUnsupported, |
| 212 | /// One of the `ListenOptions` is not supported by the Io | |
| 213 | /// implementation. | |
| 214 | OptionUnsupported, | |
| 212 | 215 | } || Io.UnexpectedError || Io.Cancelable; |
| 213 | 216 | |
| 214 | 217 | pub const ListenOptions = struct { |
| ... | ... | @@ -1057,6 +1060,9 @@ pub const Socket = struct { |
| 1057 | 1060 | /// Local end has been shut down on a connection-oriented socket, or |
| 1058 | 1061 | /// the socket was never connected. |
| 1059 | 1062 | SocketUnconnected, |
| 1063 | /// An attempt was made to send to a network/broadcast address as | |
| 1064 | /// though it was a unicast address. | |
| 1065 | AccessDenied, | |
| 1060 | 1066 | } || Io.UnexpectedError || Io.Cancelable; |
| 1061 | 1067 | |
| 1062 | 1068 | /// Transfers `data` to `dest`, connectionless, in one packet. |
| ... | ... | @@ -1167,7 +1173,6 @@ pub const Stream = struct { |
| 1167 | 1173 | |
| 1168 | 1174 | pub const Error = error{ |
| 1169 | 1175 | SystemResources, |
| 1170 | BrokenPipe, | |
| 1171 | 1176 | ConnectionResetByPeer, |
| 1172 | 1177 | Timeout, |
| 1173 | 1178 | SocketUnconnected, |
| ... | ... | @@ -1233,7 +1238,7 @@ pub const Stream = struct { |
| 1233 | 1238 | pub const Error = std.posix.SendMsgError || error{ |
| 1234 | 1239 | ConnectionResetByPeer, |
| 1235 | 1240 | SocketNotBound, |
| 1236 | MessageTooBig, | |
| 1241 | MessageOversize, | |
| 1237 | 1242 | NetworkDown, |
| 1238 | 1243 | SystemResources, |
| 1239 | 1244 | SocketUnconnected, |
lib/std/c.zig+1-1| ... | ... | @@ -4104,7 +4104,7 @@ pub const msghdr = switch (native_os) { |
| 4104 | 4104 | .visionos, |
| 4105 | 4105 | .watchos, |
| 4106 | 4106 | .serenity, // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L74-L82 |
| 4107 | => private.posix_msghdr, | |
| 4107 | => posix_msghdr, | |
| 4108 | 4108 | else => void, |
| 4109 | 4109 | }; |
| 4110 | 4110 |
lib/std/crypto/Certificate/Bundle.zig+24-21| ... | ... | @@ -70,18 +70,18 @@ pub const RescanError = RescanLinuxError || RescanMacError || RescanWithPathErro |
| 70 | 70 | /// file system standard locations for certificates. |
| 71 | 71 | /// For operating systems that do not have standard CA installations to be |
| 72 | 72 | /// found, this function clears the set of certificates. |
| 73 | pub fn rescan(cb: *Bundle, gpa: Allocator, io: Io) RescanError!void { | |
| 73 | pub fn rescan(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp) RescanError!void { | |
| 74 | 74 | switch (builtin.os.tag) { |
| 75 | .linux => return rescanLinux(cb, gpa, io), | |
| 76 | .macos => return rescanMac(cb, gpa), | |
| 77 | .freebsd, .openbsd => return rescanWithPath(cb, gpa, io, "/etc/ssl/cert.pem"), | |
| 78 | .netbsd => return rescanWithPath(cb, gpa, io, "/etc/openssl/certs/ca-certificates.crt"), | |
| 79 | .dragonfly => return rescanWithPath(cb, gpa, io, "/usr/local/etc/ssl/cert.pem"), | |
| 80 | .illumos => return rescanWithPath(cb, gpa, io, "/etc/ssl/cacert.pem"), | |
| 81 | .haiku => return rescanWithPath(cb, gpa, io, "/boot/system/data/ssl/CARootCertificates.pem"), | |
| 75 | .linux => return rescanLinux(cb, gpa, io, now), | |
| 76 | .macos => return rescanMac(cb, gpa, io, now), | |
| 77 | .freebsd, .openbsd => return rescanWithPath(cb, gpa, io, now, "/etc/ssl/cert.pem"), | |
| 78 | .netbsd => return rescanWithPath(cb, gpa, io, now, "/etc/openssl/certs/ca-certificates.crt"), | |
| 79 | .dragonfly => return rescanWithPath(cb, gpa, io, now, "/usr/local/etc/ssl/cert.pem"), | |
| 80 | .illumos => return rescanWithPath(cb, gpa, io, now, "/etc/ssl/cacert.pem"), | |
| 81 | .haiku => return rescanWithPath(cb, gpa, io, now, "/boot/system/data/ssl/CARootCertificates.pem"), | |
| 82 | 82 | // https://github.com/SerenityOS/serenity/blob/222acc9d389bc6b490d4c39539761b043a4bfcb0/Ports/ca-certificates/package.sh#L19 |
| 83 | .serenity => return rescanWithPath(cb, gpa, io, "/etc/ssl/certs/ca-certificates.crt"), | |
| 84 | .windows => return rescanWindows(cb, gpa), | |
| 83 | .serenity => return rescanWithPath(cb, gpa, io, now, "/etc/ssl/certs/ca-certificates.crt"), | |
| 84 | .windows => return rescanWindows(cb, gpa, io, now), | |
| 85 | 85 | else => {}, |
| 86 | 86 | } |
| 87 | 87 | } |
| ... | ... | @@ -91,7 +91,7 @@ const RescanMacError = @import("Bundle/macos.zig").RescanMacError; |
| 91 | 91 | |
| 92 | 92 | const RescanLinuxError = AddCertsFromFilePathError || AddCertsFromDirPathError; |
| 93 | 93 | |
| 94 | fn rescanLinux(cb: *Bundle, gpa: Allocator, io: Io) RescanLinuxError!void { | |
| 94 | fn rescanLinux(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp) RescanLinuxError!void { | |
| 95 | 95 | // Possible certificate files; stop after finding one. |
| 96 | 96 | const cert_file_paths = [_][]const u8{ |
| 97 | 97 | "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc. |
| ... | ... | @@ -114,7 +114,7 @@ fn rescanLinux(cb: *Bundle, gpa: Allocator, io: Io) RescanLinuxError!void { |
| 114 | 114 | |
| 115 | 115 | scan: { |
| 116 | 116 | for (cert_file_paths) |cert_file_path| { |
| 117 | if (addCertsFromFilePathAbsolute(cb, gpa, io, cert_file_path)) |_| { | |
| 117 | if (addCertsFromFilePathAbsolute(cb, gpa, io, now, cert_file_path)) |_| { | |
| 118 | 118 | break :scan; |
| 119 | 119 | } else |err| switch (err) { |
| 120 | 120 | error.FileNotFound => continue, |
| ... | ... | @@ -123,7 +123,7 @@ fn rescanLinux(cb: *Bundle, gpa: Allocator, io: Io) RescanLinuxError!void { |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | for (cert_dir_paths) |cert_dir_path| { |
| 126 | addCertsFromDirPathAbsolute(cb, gpa, io, cert_dir_path) catch |err| switch (err) { | |
| 126 | addCertsFromDirPathAbsolute(cb, gpa, io, now, cert_dir_path) catch |err| switch (err) { | |
| 127 | 127 | error.FileNotFound => continue, |
| 128 | 128 | else => |e| return e, |
| 129 | 129 | }; |
| ... | ... | @@ -135,10 +135,10 @@ fn rescanLinux(cb: *Bundle, gpa: Allocator, io: Io) RescanLinuxError!void { |
| 135 | 135 | |
| 136 | 136 | const RescanWithPathError = AddCertsFromFilePathError; |
| 137 | 137 | |
| 138 | fn rescanWithPath(cb: *Bundle, gpa: Allocator, io: Io, cert_file_path: []const u8) RescanWithPathError!void { | |
| 138 | fn rescanWithPath(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, cert_file_path: []const u8) RescanWithPathError!void { | |
| 139 | 139 | cb.bytes.clearRetainingCapacity(); |
| 140 | 140 | cb.map.clearRetainingCapacity(); |
| 141 | try addCertsFromFilePathAbsolute(cb, gpa, io, cert_file_path); | |
| 141 | try addCertsFromFilePathAbsolute(cb, gpa, io, now, cert_file_path); | |
| 142 | 142 | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); |
| 143 | 143 | } |
| 144 | 144 | |
| ... | ... | @@ -187,17 +187,18 @@ pub fn addCertsFromDirPathAbsolute( |
| 187 | 187 | cb: *Bundle, |
| 188 | 188 | gpa: Allocator, |
| 189 | 189 | io: Io, |
| 190 | now: Io.Timestamp, | |
| 190 | 191 | abs_dir_path: []const u8, |
| 191 | 192 | ) AddCertsFromDirPathError!void { |
| 192 | 193 | assert(fs.path.isAbsolute(abs_dir_path)); |
| 193 | 194 | var iterable_dir = try fs.openDirAbsolute(abs_dir_path, .{ .iterate = true }); |
| 194 | 195 | defer iterable_dir.close(); |
| 195 | return addCertsFromDir(cb, gpa, io, iterable_dir); | |
| 196 | return addCertsFromDir(cb, gpa, io, now, iterable_dir); | |
| 196 | 197 | } |
| 197 | 198 | |
| 198 | 199 | pub const AddCertsFromDirError = AddCertsFromFilePathError; |
| 199 | 200 | |
| 200 | pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, io: Io, iterable_dir: fs.Dir) AddCertsFromDirError!void { | |
| 201 | pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, iterable_dir: fs.Dir) AddCertsFromDirError!void { | |
| 201 | 202 | var it = iterable_dir.iterate(); |
| 202 | 203 | while (try it.next()) |entry| { |
| 203 | 204 | switch (entry.kind) { |
| ... | ... | @@ -205,7 +206,7 @@ pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, io: Io, iterable_dir: fs.Dir |
| 205 | 206 | else => continue, |
| 206 | 207 | } |
| 207 | 208 | |
| 208 | try addCertsFromFilePath(cb, gpa, io, iterable_dir.adaptToNewApi(), entry.name); | |
| 209 | try addCertsFromFilePath(cb, gpa, io, now, iterable_dir.adaptToNewApi(), entry.name); | |
| 209 | 210 | } |
| 210 | 211 | } |
| 211 | 212 | |
| ... | ... | @@ -215,9 +216,9 @@ pub fn addCertsFromFilePathAbsolute( |
| 215 | 216 | cb: *Bundle, |
| 216 | 217 | gpa: Allocator, |
| 217 | 218 | io: Io, |
| 219 | now: Io.Timestamp, | |
| 218 | 220 | abs_file_path: []const u8, |
| 219 | 221 | ) AddCertsFromFilePathError!void { |
| 220 | const now = try Io.Clock.real.now(io); | |
| 221 | 222 | var file = try fs.openFileAbsolute(abs_file_path, .{}); |
| 222 | 223 | defer file.close(); |
| 223 | 224 | var file_reader = file.reader(io, &.{}); |
| ... | ... | @@ -228,10 +229,10 @@ pub fn addCertsFromFilePath( |
| 228 | 229 | cb: *Bundle, |
| 229 | 230 | gpa: Allocator, |
| 230 | 231 | io: Io, |
| 232 | now: Io.Timestamp, | |
| 231 | 233 | dir: Io.Dir, |
| 232 | 234 | sub_file_path: []const u8, |
| 233 | 235 | ) AddCertsFromFilePathError!void { |
| 234 | const now = try Io.Clock.real.now(io); | |
| 235 | 236 | var file = try dir.openFile(io, sub_file_path, .{}); |
| 236 | 237 | defer file.close(io); |
| 237 | 238 | var file_reader = file.reader(io, &.{}); |
| ... | ... | @@ -335,5 +336,7 @@ test "scan for OS-provided certificates" { |
| 335 | 336 | var bundle: Bundle = .{}; |
| 336 | 337 | defer bundle.deinit(gpa); |
| 337 | 338 | |
| 338 | try bundle.rescan(gpa, io); | |
| 339 | const now = try Io.Clock.real.now(io); | |
| 340 | ||
| 341 | try bundle.rescan(gpa, io, now); | |
| 339 | 342 | } |
lib/std/crypto/Certificate/Bundle/macos.zig+6-6| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const assert = std.debug.assert; |
| 3 | 4 | const fs = std.fs; |
| 4 | 5 | const mem = std.mem; |
| ... | ... | @@ -7,7 +8,7 @@ const Bundle = @import("../Bundle.zig"); |
| 7 | 8 | |
| 8 | 9 | pub const RescanMacError = Allocator.Error || fs.File.OpenError || fs.File.ReadError || fs.File.SeekError || Bundle.ParseCertError || error{EndOfStream}; |
| 9 | 10 | |
| 10 | pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { | |
| 11 | pub fn rescanMac(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp) RescanMacError!void { | |
| 11 | 12 | cb.bytes.clearRetainingCapacity(); |
| 12 | 13 | cb.map.clearRetainingCapacity(); |
| 13 | 14 | |
| ... | ... | @@ -16,6 +17,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { |
| 16 | 17 | "/Library/Keychains/System.keychain", |
| 17 | 18 | }; |
| 18 | 19 | |
| 20 | _ = io; // TODO migrate file system to use std.Io | |
| 19 | 21 | for (keychain_paths) |keychain_path| { |
| 20 | 22 | const bytes = std.fs.cwd().readFileAlloc(keychain_path, gpa, .limited(std.math.maxInt(u32))) catch |err| switch (err) { |
| 21 | 23 | error.StreamTooLong => return error.FileTooBig, |
| ... | ... | @@ -23,8 +25,8 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { |
| 23 | 25 | }; |
| 24 | 26 | defer gpa.free(bytes); |
| 25 | 27 | |
| 26 | var reader: std.Io.Reader = .fixed(bytes); | |
| 27 | scanReader(cb, gpa, &reader) catch |err| switch (err) { | |
| 28 | var reader: Io.Reader = .fixed(bytes); | |
| 29 | scanReader(cb, gpa, &reader, now.toSeconds()) catch |err| switch (err) { | |
| 28 | 30 | error.ReadFailed => unreachable, // prebuffered |
| 29 | 31 | else => |e| return e, |
| 30 | 32 | }; |
| ... | ... | @@ -33,7 +35,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { |
| 33 | 35 | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); |
| 34 | 36 | } |
| 35 | 37 | |
| 36 | fn scanReader(cb: *Bundle, gpa: Allocator, reader: *std.Io.Reader) !void { | |
| 38 | fn scanReader(cb: *Bundle, gpa: Allocator, reader: *Io.Reader, now_sec: i64) !void { | |
| 37 | 39 | const db_header = try reader.takeStruct(ApplDbHeader, .big); |
| 38 | 40 | assert(mem.eql(u8, &db_header.signature, "kych")); |
| 39 | 41 | |
| ... | ... | @@ -49,8 +51,6 @@ fn scanReader(cb: *Bundle, gpa: Allocator, reader: *std.Io.Reader) !void { |
| 49 | 51 | table_list[table_idx] = try reader.takeInt(u32, .big); |
| 50 | 52 | } |
| 51 | 53 | |
| 52 | const now_sec = std.time.timestamp(); | |
| 53 | ||
| 54 | 54 | for (table_list) |table_offset| { |
| 55 | 55 | reader.seek = db_header.schema_offset + table_offset; |
| 56 | 56 |
lib/std/debug/SelfInfo/MachO.zig+3| ... | ... | @@ -117,11 +117,14 @@ pub fn unwindFrame(si: *SelfInfo, gpa: Allocator, context: *UnwindContext) Error |
| 117 | 117 | error.ReadFailed, |
| 118 | 118 | error.OutOfMemory, |
| 119 | 119 | error.Unexpected, |
| 120 | error.Canceled, | |
| 120 | 121 | => |e| return e, |
| 122 | ||
| 121 | 123 | error.UnsupportedRegister, |
| 122 | 124 | error.UnsupportedAddrSize, |
| 123 | 125 | error.UnimplementedUserOpcode, |
| 124 | 126 | => return error.UnsupportedDebugInfo, |
| 127 | ||
| 125 | 128 | error.Overflow, |
| 126 | 129 | error.EndOfStream, |
| 127 | 130 | error.StreamTooLong, |
lib/std/fs.zig+2| ... | ... | @@ -458,6 +458,8 @@ pub const SelfExePathError = error{ |
| 458 | 458 | /// On Windows, the volume does not contain a recognized file system. File |
| 459 | 459 | /// system drivers might not be loaded, or the volume may be corrupt. |
| 460 | 460 | UnrecognizedVolume, |
| 461 | ||
| 462 | Canceled, | |
| 461 | 463 | } || posix.SysCtlError; |
| 462 | 464 | |
| 463 | 465 | /// `selfExePath` except allocates the result on the heap. |
lib/std/http/Client.zig+13-10| ... | ... | @@ -35,9 +35,11 @@ tls_buffer_size: if (disable_tls) u0 else usize = if (disable_tls) 0 else std.cr |
| 35 | 35 | /// traffic over connections created with this `Client`. |
| 36 | 36 | ssl_key_log: ?*std.crypto.tls.Client.SslKeyLog = null, |
| 37 | 37 | |
| 38 | /// When this is `true`, the next time this client performs an HTTPS request, | |
| 39 | /// it will first rescan the system for root certificates. | |
| 40 | next_https_rescan_certs: bool = true, | |
| 38 | /// The time used to decide whether certificates are expired. | |
| 39 | /// | |
| 40 | /// When this is `null`, the next time this client performs an HTTPS request, | |
| 41 | /// it will first check the time and rescan the system for root certificates. | |
| 42 | now: ?Io.Timestamp = null, | |
| 41 | 43 | |
| 42 | 44 | /// The pool of connections that can be reused (and currently in use). |
| 43 | 45 | connection_pool: ConnectionPool = .{}, |
| ... | ... | @@ -295,6 +297,7 @@ pub const Connection = struct { |
| 295 | 297 | client: std.crypto.tls.Client, |
| 296 | 298 | connection: Connection, |
| 297 | 299 | |
| 300 | /// Asserts that `client.now` is non-null. | |
| 298 | 301 | fn create( |
| 299 | 302 | client: *Client, |
| 300 | 303 | remote_host: HostName, |
| ... | ... | @@ -320,7 +323,6 @@ pub const Connection = struct { |
| 320 | 323 | const tls: *Tls = @ptrCast(base); |
| 321 | 324 | var random_buffer: [176]u8 = undefined; |
| 322 | 325 | std.crypto.random.bytes(&random_buffer); |
| 323 | const now_ts = if (Io.Clock.real.now(io)) |ts| ts.toSeconds() else |err| return err; | |
| 324 | 326 | tls.* = .{ |
| 325 | 327 | .connection = .{ |
| 326 | 328 | .client = client, |
| ... | ... | @@ -333,7 +335,7 @@ pub const Connection = struct { |
| 333 | 335 | .closing = false, |
| 334 | 336 | .protocol = .tls, |
| 335 | 337 | }, |
| 336 | // TODO data race here on ca_bundle if the user sets next_https_rescan_certs to true | |
| 338 | // TODO data race here on ca_bundle if the user sets `now` to null | |
| 337 | 339 | .client = std.crypto.tls.Client.init( |
| 338 | 340 | &tls.connection.stream_reader.interface, |
| 339 | 341 | &tls.connection.stream_writer.interface, |
| ... | ... | @@ -344,7 +346,7 @@ pub const Connection = struct { |
| 344 | 346 | .read_buffer = tls_read_buffer, |
| 345 | 347 | .write_buffer = socket_write_buffer, |
| 346 | 348 | .entropy = &random_buffer, |
| 347 | .realtime_now_seconds = now_ts, | |
| 349 | .realtime_now_seconds = client.now.?.toSeconds(), | |
| 348 | 350 | // This is appropriate for HTTPS because the HTTP headers contain |
| 349 | 351 | // the content length which is used to detect truncation attacks. |
| 350 | 352 | .allow_truncation_attacks = true, |
| ... | ... | @@ -1687,14 +1689,15 @@ pub fn request( |
| 1687 | 1689 | |
| 1688 | 1690 | if (protocol == .tls) { |
| 1689 | 1691 | if (disable_tls) unreachable; |
| 1690 | if (@atomicLoad(bool, &client.next_https_rescan_certs, .acquire)) { | |
| 1692 | { | |
| 1691 | 1693 | client.ca_bundle_mutex.lock(); |
| 1692 | 1694 | defer client.ca_bundle_mutex.unlock(); |
| 1693 | 1695 | |
| 1694 | if (client.next_https_rescan_certs) { | |
| 1695 | client.ca_bundle.rescan(client.allocator, io) catch | |
| 1696 | if (client.now == null) { | |
| 1697 | const now = try Io.Clock.real.now(io); | |
| 1698 | client.now = now; | |
| 1699 | client.ca_bundle.rescan(client.allocator, io, now) catch | |
| 1696 | 1700 | return error.CertificateBundleLoadFailure; |
| 1697 | @atomicStore(bool, &client.next_https_rescan_certs, false, .release); | |
| 1698 | 1701 | } |
| 1699 | 1702 | } |
| 1700 | 1703 | } |
lib/std/http/Server.zig+4-4| ... | ... | @@ -688,7 +688,7 @@ pub const WebSocket = struct { |
| 688 | 688 | pub const ReadSmallTextMessageError = error{ |
| 689 | 689 | ConnectionClose, |
| 690 | 690 | UnexpectedOpCode, |
| 691 | MessageTooBig, | |
| 691 | MessageOversize, | |
| 692 | 692 | MissingMaskBit, |
| 693 | 693 | ReadFailed, |
| 694 | 694 | EndOfStream, |
| ... | ... | @@ -717,15 +717,15 @@ pub const WebSocket = struct { |
| 717 | 717 | _ => return error.UnexpectedOpCode, |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | if (!h0.fin) return error.MessageTooBig; | |
| 720 | if (!h0.fin) return error.MessageOversize; | |
| 721 | 721 | if (!h1.mask) return error.MissingMaskBit; |
| 722 | 722 | |
| 723 | 723 | const len: usize = switch (h1.payload_len) { |
| 724 | 724 | .len16 => try in.takeInt(u16, .big), |
| 725 | .len64 => std.math.cast(usize, try in.takeInt(u64, .big)) orelse return error.MessageTooBig, | |
| 725 | .len64 => std.math.cast(usize, try in.takeInt(u64, .big)) orelse return error.MessageOversize, | |
| 726 | 726 | else => @intFromEnum(h1.payload_len), |
| 727 | 727 | }; |
| 728 | if (len > in.buffer.len) return error.MessageTooBig; | |
| 728 | if (len > in.buffer.len) return error.MessageOversize; | |
| 729 | 729 | const mask: u32 = @bitCast((try in.takeArray(4)).*); |
| 730 | 730 | const payload = try in.take(len); |
| 731 | 731 |
lib/std/os/windows.zig+1-1| ... | ... | @@ -1653,7 +1653,7 @@ pub fn WSASocketW( |
| 1653 | 1653 | const rc = ws2_32.WSASocketW(af, socket_type, protocol, protocolInfo, g, dwFlags); |
| 1654 | 1654 | if (rc == ws2_32.INVALID_SOCKET) { |
| 1655 | 1655 | switch (ws2_32.WSAGetLastError()) { |
| 1656 | .WSAEAFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 1656 | .WSAEAFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 1657 | 1657 | .WSAEMFILE => return error.ProcessFdQuotaExceeded, |
| 1658 | 1658 | .WSAENOBUFS => return error.SystemResources, |
| 1659 | 1659 | .WSAEPROTONOSUPPORT => return error.ProtocolNotSupported, |
lib/std/posix.zig+26-26| ... | ... | @@ -1205,7 +1205,7 @@ pub const WriteError = error{ |
| 1205 | 1205 | |
| 1206 | 1206 | /// The socket type requires that message be sent atomically, and the size of the message |
| 1207 | 1207 | /// to be sent made this impossible. The message is not transmitted. |
| 1208 | MessageTooBig, | |
| 1208 | MessageOversize, | |
| 1209 | 1209 | } || UnexpectedError; |
| 1210 | 1210 | |
| 1211 | 1211 | /// Write to a file descriptor. |
| ... | ... | @@ -1287,7 +1287,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 1287 | 1287 | .CONNRESET => return error.ConnectionResetByPeer, |
| 1288 | 1288 | .BUSY => return error.DeviceBusy, |
| 1289 | 1289 | .NXIO => return error.NoDevice, |
| 1290 | .MSGSIZE => return error.MessageTooBig, | |
| 1290 | .MSGSIZE => return error.MessageOversize, | |
| 1291 | 1291 | else => |err| return unexpectedErrno(err), |
| 1292 | 1292 | } |
| 1293 | 1293 | } |
| ... | ... | @@ -3487,7 +3487,7 @@ pub const SocketError = error{ |
| 3487 | 3487 | AccessDenied, |
| 3488 | 3488 | |
| 3489 | 3489 | /// The implementation does not support the specified address family. |
| 3490 | AddressFamilyNotSupported, | |
| 3490 | AddressFamilyUnsupported, | |
| 3491 | 3491 | |
| 3492 | 3492 | /// Unknown protocol, or protocol family not available. |
| 3493 | 3493 | ProtocolFamilyNotAvailable, |
| ... | ... | @@ -3553,7 +3553,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t |
| 3553 | 3553 | return fd; |
| 3554 | 3554 | }, |
| 3555 | 3555 | .ACCES => return error.AccessDenied, |
| 3556 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 3556 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 3557 | 3557 | .INVAL => return error.ProtocolFamilyNotAvailable, |
| 3558 | 3558 | .MFILE => return error.ProcessFdQuotaExceeded, |
| 3559 | 3559 | .NFILE => return error.SystemFdQuotaExceeded, |
| ... | ... | @@ -3593,7 +3593,7 @@ pub fn socketpair(domain: u32, socket_type: u32, protocol: u32) SocketError![2]s |
| 3593 | 3593 | return socks; |
| 3594 | 3594 | }, |
| 3595 | 3595 | .ACCES => return error.AccessDenied, |
| 3596 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 3596 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 3597 | 3597 | .INVAL => return error.ProtocolFamilyNotAvailable, |
| 3598 | 3598 | .MFILE => return error.ProcessFdQuotaExceeded, |
| 3599 | 3599 | .NFILE => return error.SystemFdQuotaExceeded, |
| ... | ... | @@ -3676,7 +3676,7 @@ pub const BindError = error{ |
| 3676 | 3676 | AddressNotAvailable, |
| 3677 | 3677 | |
| 3678 | 3678 | /// The address is not valid for the address family of socket. |
| 3679 | AddressFamilyNotSupported, | |
| 3679 | AddressFamilyUnsupported, | |
| 3680 | 3680 | |
| 3681 | 3681 | /// Too many symbolic links were encountered in resolving addr. |
| 3682 | 3682 | SymLinkLoop, |
| ... | ... | @@ -3733,7 +3733,7 @@ pub fn bind(sock: socket_t, addr: *const sockaddr, len: socklen_t) BindError!voi |
| 3733 | 3733 | .BADF => unreachable, // always a race condition if this error is returned |
| 3734 | 3734 | .INVAL => unreachable, // invalid parameters |
| 3735 | 3735 | .NOTSOCK => unreachable, // invalid `sockfd` |
| 3736 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 3736 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 3737 | 3737 | .ADDRNOTAVAIL => return error.AddressNotAvailable, |
| 3738 | 3738 | .FAULT => unreachable, // invalid `addr` pointer |
| 3739 | 3739 | .LOOP => return error.SymLinkLoop, |
| ... | ... | @@ -4192,7 +4192,7 @@ pub const ConnectError = error{ |
| 4192 | 4192 | AddressNotAvailable, |
| 4193 | 4193 | |
| 4194 | 4194 | /// The passed address didn't have the correct address family in its sa_family field. |
| 4195 | AddressFamilyNotSupported, | |
| 4195 | AddressFamilyUnsupported, | |
| 4196 | 4196 | |
| 4197 | 4197 | /// Insufficient entries in the routing cache. |
| 4198 | 4198 | SystemResources, |
| ... | ... | @@ -4247,7 +4247,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne |
| 4247 | 4247 | .WSAEWOULDBLOCK => return error.WouldBlock, |
| 4248 | 4248 | .WSAEACCES => unreachable, |
| 4249 | 4249 | .WSAENOBUFS => return error.SystemResources, |
| 4250 | .WSAEAFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 4250 | .WSAEAFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 4251 | 4251 | else => |err| return windows.unexpectedWSAError(err), |
| 4252 | 4252 | } |
| 4253 | 4253 | return; |
| ... | ... | @@ -4260,7 +4260,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne |
| 4260 | 4260 | .PERM => return error.PermissionDenied, |
| 4261 | 4261 | .ADDRINUSE => return error.AddressInUse, |
| 4262 | 4262 | .ADDRNOTAVAIL => return error.AddressNotAvailable, |
| 4263 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 4263 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 4264 | 4264 | .AGAIN, .INPROGRESS => return error.WouldBlock, |
| 4265 | 4265 | .ALREADY => return error.ConnectionPending, |
| 4266 | 4266 | .BADF => unreachable, // sockfd is not a valid open file descriptor. |
| ... | ... | @@ -4322,7 +4322,7 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void { |
| 4322 | 4322 | .PERM => return error.PermissionDenied, |
| 4323 | 4323 | .ADDRINUSE => return error.AddressInUse, |
| 4324 | 4324 | .ADDRNOTAVAIL => return error.AddressNotAvailable, |
| 4325 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 4325 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 4326 | 4326 | .AGAIN => return error.SystemResources, |
| 4327 | 4327 | .ALREADY => return error.ConnectionPending, |
| 4328 | 4328 | .BADF => unreachable, // sockfd is not a valid open file descriptor. |
| ... | ... | @@ -6039,7 +6039,7 @@ pub const SendError = error{ |
| 6039 | 6039 | |
| 6040 | 6040 | /// The socket type requires that message be sent atomically, and the size of the message |
| 6041 | 6041 | /// to be sent made this impossible. The message is not transmitted. |
| 6042 | MessageTooBig, | |
| 6042 | MessageOversize, | |
| 6043 | 6043 | |
| 6044 | 6044 | /// The output queue for a network interface was full. This generally indicates that the |
| 6045 | 6045 | /// interface has stopped sending, but may be caused by transient congestion. (Normally, |
| ... | ... | @@ -6066,7 +6066,7 @@ pub const SendError = error{ |
| 6066 | 6066 | |
| 6067 | 6067 | pub const SendMsgError = SendError || error{ |
| 6068 | 6068 | /// The passed address didn't have the correct address family in its sa_family field. |
| 6069 | AddressFamilyNotSupported, | |
| 6069 | AddressFamilyUnsupported, | |
| 6070 | 6070 | |
| 6071 | 6071 | /// Returned when socket is AF.UNIX and the given path has a symlink loop. |
| 6072 | 6072 | SymLinkLoop, |
| ... | ... | @@ -6098,10 +6098,10 @@ pub fn sendmsg( |
| 6098 | 6098 | .WSAEACCES => return error.AccessDenied, |
| 6099 | 6099 | .WSAEADDRNOTAVAIL => return error.AddressNotAvailable, |
| 6100 | 6100 | .WSAECONNRESET => return error.ConnectionResetByPeer, |
| 6101 | .WSAEMSGSIZE => return error.MessageTooBig, | |
| 6101 | .WSAEMSGSIZE => return error.MessageOversize, | |
| 6102 | 6102 | .WSAENOBUFS => return error.SystemResources, |
| 6103 | 6103 | .WSAENOTSOCK => return error.FileDescriptorNotASocket, |
| 6104 | .WSAEAFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 6104 | .WSAEAFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 6105 | 6105 | .WSAEDESTADDRREQ => unreachable, // A destination address is required. |
| 6106 | 6106 | .WSAEFAULT => unreachable, // The lpBuffers, lpTo, lpOverlapped, lpNumberOfBytesSent, or lpCompletionRoutine parameters are not part of the user address space, or the lpTo parameter is too small. |
| 6107 | 6107 | .WSAEHOSTUNREACH => return error.NetworkUnreachable, |
| ... | ... | @@ -6133,13 +6133,13 @@ pub fn sendmsg( |
| 6133 | 6133 | .INTR => continue, |
| 6134 | 6134 | .INVAL => unreachable, // Invalid argument passed. |
| 6135 | 6135 | .ISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified |
| 6136 | .MSGSIZE => return error.MessageTooBig, | |
| 6136 | .MSGSIZE => return error.MessageOversize, | |
| 6137 | 6137 | .NOBUFS => return error.SystemResources, |
| 6138 | 6138 | .NOMEM => return error.SystemResources, |
| 6139 | 6139 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. |
| 6140 | 6140 | .OPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type. |
| 6141 | 6141 | .PIPE => return error.BrokenPipe, |
| 6142 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 6142 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 6143 | 6143 | .LOOP => return error.SymLinkLoop, |
| 6144 | 6144 | .NAMETOOLONG => return error.NameTooLong, |
| 6145 | 6145 | .NOENT => return error.FileNotFound, |
| ... | ... | @@ -6178,7 +6178,7 @@ pub const SendToError = SendMsgError || error{ |
| 6178 | 6178 | /// Otherwise, the address of the target is given by `dest_addr` with `addrlen` specifying its size. |
| 6179 | 6179 | /// |
| 6180 | 6180 | /// If the message is too long to pass atomically through the underlying protocol, |
| 6181 | /// `SendError.MessageTooBig` is returned, and the message is not transmitted. | |
| 6181 | /// `SendError.MessageOversize` is returned, and the message is not transmitted. | |
| 6182 | 6182 | /// |
| 6183 | 6183 | /// There is no indication of failure to deliver. |
| 6184 | 6184 | /// |
| ... | ... | @@ -6201,10 +6201,10 @@ pub fn sendto( |
| 6201 | 6201 | .WSAEACCES => return error.AccessDenied, |
| 6202 | 6202 | .WSAEADDRNOTAVAIL => return error.AddressNotAvailable, |
| 6203 | 6203 | .WSAECONNRESET => return error.ConnectionResetByPeer, |
| 6204 | .WSAEMSGSIZE => return error.MessageTooBig, | |
| 6204 | .WSAEMSGSIZE => return error.MessageOversize, | |
| 6205 | 6205 | .WSAENOBUFS => return error.SystemResources, |
| 6206 | 6206 | .WSAENOTSOCK => return error.FileDescriptorNotASocket, |
| 6207 | .WSAEAFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 6207 | .WSAEAFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 6208 | 6208 | .WSAEDESTADDRREQ => unreachable, // A destination address is required. |
| 6209 | 6209 | .WSAEFAULT => unreachable, // The lpBuffers, lpTo, lpOverlapped, lpNumberOfBytesSent, or lpCompletionRoutine parameters are not part of the user address space, or the lpTo parameter is too small. |
| 6210 | 6210 | .WSAEHOSTUNREACH => return error.NetworkUnreachable, |
| ... | ... | @@ -6238,13 +6238,13 @@ pub fn sendto( |
| 6238 | 6238 | .INTR => continue, |
| 6239 | 6239 | .INVAL => return error.UnreachableAddress, |
| 6240 | 6240 | .ISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified |
| 6241 | .MSGSIZE => return error.MessageTooBig, | |
| 6241 | .MSGSIZE => return error.MessageOversize, | |
| 6242 | 6242 | .NOBUFS => return error.SystemResources, |
| 6243 | 6243 | .NOMEM => return error.SystemResources, |
| 6244 | 6244 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. |
| 6245 | 6245 | .OPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type. |
| 6246 | 6246 | .PIPE => return error.BrokenPipe, |
| 6247 | .AFNOSUPPORT => return error.AddressFamilyNotSupported, | |
| 6247 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | |
| 6248 | 6248 | .LOOP => return error.SymLinkLoop, |
| 6249 | 6249 | .NAMETOOLONG => return error.NameTooLong, |
| 6250 | 6250 | .NOENT => return error.FileNotFound, |
| ... | ... | @@ -6284,7 +6284,7 @@ pub fn send( |
| 6284 | 6284 | flags: u32, |
| 6285 | 6285 | ) SendError!usize { |
| 6286 | 6286 | return sendto(sockfd, buf, flags, null, 0) catch |err| switch (err) { |
| 6287 | error.AddressFamilyNotSupported => unreachable, | |
| 6287 | error.AddressFamilyUnsupported => unreachable, | |
| 6288 | 6288 | error.SymLinkLoop => unreachable, |
| 6289 | 6289 | error.NameTooLong => unreachable, |
| 6290 | 6290 | error.FileNotFound => unreachable, |
| ... | ... | @@ -6471,7 +6471,7 @@ pub const RecvFromError = error{ |
| 6471 | 6471 | SocketNotBound, |
| 6472 | 6472 | |
| 6473 | 6473 | /// The UDP message was too big for the buffer and part of it has been discarded |
| 6474 | MessageTooBig, | |
| 6474 | MessageOversize, | |
| 6475 | 6475 | |
| 6476 | 6476 | /// The network subsystem has failed. |
| 6477 | 6477 | NetworkDown, |
| ... | ... | @@ -6504,7 +6504,7 @@ pub fn recvfrom( |
| 6504 | 6504 | .WSANOTINITIALISED => unreachable, |
| 6505 | 6505 | .WSAECONNRESET => return error.ConnectionResetByPeer, |
| 6506 | 6506 | .WSAEINVAL => return error.SocketNotBound, |
| 6507 | .WSAEMSGSIZE => return error.MessageTooBig, | |
| 6507 | .WSAEMSGSIZE => return error.MessageOversize, | |
| 6508 | 6508 | .WSAENETDOWN => return error.NetworkDown, |
| 6509 | 6509 | .WSAENOTCONN => return error.SocketUnconnected, |
| 6510 | 6510 | .WSAEWOULDBLOCK => return error.WouldBlock, |
| ... | ... | @@ -6575,7 +6575,7 @@ pub fn recvmsg( |
| 6575 | 6575 | .NOMEM => return error.SystemResources, |
| 6576 | 6576 | .NOTCONN => return error.SocketUnconnected, |
| 6577 | 6577 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. |
| 6578 | .MSGSIZE => return error.MessageTooBig, | |
| 6578 | .MSGSIZE => return error.MessageOversize, | |
| 6579 | 6579 | .PIPE => return error.BrokenPipe, |
| 6580 | 6580 | .OPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type. |
| 6581 | 6581 | .CONNRESET => return error.ConnectionResetByPeer, |