authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-19 07:09:28-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-29 06:20:50-07:00
logb215f8667a0cc59888926fcfcbb4be4370bd2216
tree96afce2234d478e46738e540f198d34a6bac2703
parent83e4ff6f4c739096806b951e7c6e54399c18d19b

std.Io.net.HostName.ResolvConf: ignore nameservers above max


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

lib/std/Io/net/HostName.zig+6-3
...@@ -310,6 +310,8 @@ pub const ResolvConf = struct {...@@ -310,6 +310,8 @@ pub const ResolvConf = struct {
310 search_buffer: [max_len]u8,310 search_buffer: [max_len]u8,
311 search_len: usize,311 search_len: usize,
312312
313 /// According to resolv.conf(5) there is a maximum of 3 nameservers in this
314 /// file.
313 pub const max_nameservers = 3;315 pub const max_nameservers = 3;
314316
315 /// Returns `error.StreamTooLong` if a line is longer than 512 bytes.317 /// Returns `error.StreamTooLong` if a line is longer than 512 bytes.
...@@ -394,9 +396,10 @@ pub const ResolvConf = struct {...@@ -394,9 +396,10 @@ pub const ResolvConf = struct {
394 }396 }
395397
396 fn addNumeric(rc: *ResolvConf, io: Io, name: []const u8, port: u16) !void {398 fn addNumeric(rc: *ResolvConf, io: Io, name: []const u8, port: u16) !void {
397 assert(rc.nameservers_len < rc.nameservers_buffer.len);399 if (rc.nameservers_len < rc.nameservers_buffer.len) {
398 rc.nameservers_buffer[rc.nameservers_len] = try .resolve(io, name, port);400 rc.nameservers_buffer[rc.nameservers_len] = try .resolve(io, name, port);
399 rc.nameservers_len += 1;401 rc.nameservers_len += 1;
402 }
400 }403 }
401404
402 pub fn nameservers(rc: *const ResolvConf) []const IpAddress {405 pub fn nameservers(rc: *const ResolvConf) []const IpAddress {