From adf590d58cb395cf7c726e6d22b3bbb2100643a6 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 11 Jun 2026 21:58:40 -0700 Subject: [PATCH] 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` --- lib/std/Io/Threaded.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 4ae5be040f3bd15e529f9f44b23c2d54ce2324a8..48a0f798cd20d89eac4c928964e80d2ff65b1953 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -13704,7 +13704,7 @@ fn netLookupFallible( // Check for equal to "localhost(.)" or ends in ".localhost(.)" const localhost = if (name[name.len - 1] == '.') "localhost." else "localhost"; if (std.mem.endsWith(u8, name, localhost) and - (name.len == localhost.len or name[name.len - localhost.len] == '.')) + (name.len == localhost.len or name[name.len - localhost.len - 1] == '.')) { var results_buffer: [3]HostName.LookupResult = undefined; var results_index: usize = 0; -- 2.54.0