From 1136d36362f87ebad83007ea31d88c8427c0a019 Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Fri, 19 Dec 2025 03:24:02 -0800 Subject: [PATCH] windows: Remove BadPathName from error set of GetFinalPathNameByHandle These validations are really only checking for kernel/mount manager bugs, so an assert seems more appropriate. --- lib/std/os/windows.zig | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index 2015759754..3ea48585ff 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -3599,7 +3599,6 @@ test QueryObjectName { pub const GetFinalPathNameByHandleError = error{ AccessDenied, - BadPathName, FileNotFound, NameTooLong, /// The volume does not contain a recognized file system. File system @@ -3705,6 +3704,7 @@ pub fn GetFinalPathNameByHandle( error.WouldBlock => return error.Unexpected, error.NetworkNotFound => return error.Unexpected, error.AntivirusInterference => return error.Unexpected, + error.BadPathName => return error.Unexpected, else => |e| return e, }; defer CloseHandle(mgmt_handle); @@ -3750,9 +3750,7 @@ pub fn GetFinalPathNameByHandle( const total_len = drive_letter.len + file_name_u16.len; // Validate that DOS does not contain any spurious nul bytes. - if (mem.findScalar(u16, out_buffer[0..total_len], 0)) |_| { - return error.BadPathName; - } + assert(mem.findScalar(u16, out_buffer[0..total_len], 0) == null); return out_buffer[0..total_len]; } else if (mountmgrIsVolumeName(symlink)) { @@ -3802,9 +3800,7 @@ pub fn GetFinalPathNameByHandle( const total_len = volume_path.len + file_name_u16.len; // Validate that DOS does not contain any spurious nul bytes. - if (mem.findScalar(u16, out_buffer[0..total_len], 0)) |_| { - return error.BadPathName; - } + assert(mem.findScalar(u16, out_buffer[0..total_len], 0) == null); return out_buffer[0..total_len]; }