From 3a9344d8fc757e6c771f689fce0db912e39115e9 Mon Sep 17 00:00:00 2001 From: Marijn Stollenga Date: Fri, 1 Jul 2022 20:19:13 +0200 Subject: [PATCH] Return invalid argument in sendto instead of unreachable, since this can happen with user-side errors --- lib/std/os.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/std/os.zig b/lib/std/os.zig index f0bd3dad95..9270a52adb 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -5781,7 +5781,10 @@ pub fn sendmsg( } } -pub const SendToError = SendMsgError; +pub const SendToError = SendMsgError || error{ + /// The destination address is not reachable by the bound address. + UnreachableAddress, +}; /// Transmit a message to another socket. /// @@ -5858,7 +5861,7 @@ pub fn sendto( .DESTADDRREQ => unreachable, // The socket is not connection-mode, and no peer address is set. .FAULT => unreachable, // An invalid user space address was specified for an argument. .INTR => continue, - .INVAL => unreachable, // Invalid argument passed. + .INVAL => return error.UnreachableAddress, .ISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified .MSGSIZE => return error.MessageTooBig, .NOBUFS => return error.SystemResources,