authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-11 21:58:40-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-06-17 01:41:22+02:00
logadf590d58cb395cf7c726e6d22b3bbb2100643a6
tree9ca32ed42dbb158abc392d078cc9652e0c7aa6cf
parente6be5cfe3e280656339d81fdd0cc7451941eba09

std.Io.Threaded: fix off-by-one in netLookup for '.localhost' detection

under this condition, `name[name.len - localhost.len]` will always be 'l' move back one more to observe the dot this minus is safe because this branch is only reachable if `name.len > localhost.len`

1 files changed, 1 insertions(+), 1 deletions(-)

lib/std/Io/Threaded.zig+1-1
...@@ -13704,7 +13704,7 @@ fn netLookupFallible(...@@ -13704,7 +13704,7 @@ fn netLookupFallible(
13704 // Check for equal to "localhost(.)" or ends in ".localhost(.)"13704 // Check for equal to "localhost(.)" or ends in ".localhost(.)"
13705 const localhost = if (name[name.len - 1] == '.') "localhost." else "localhost";13705 const localhost = if (name[name.len - 1] == '.') "localhost." else "localhost";
13706 if (std.mem.endsWith(u8, name, localhost) and13706 if (std.mem.endsWith(u8, name, localhost) and
13707 (name.len == localhost.len or name[name.len - localhost.len] == '.'))13707 (name.len == localhost.len or name[name.len - localhost.len - 1] == '.'))
13708 {13708 {
13709 var results_buffer: [3]HostName.LookupResult = undefined;13709 var results_buffer: [3]HostName.LookupResult = undefined;
13710 var results_index: usize = 0;13710 var results_index: usize = 0;