| author | |
| committer | |
| log | 5537704f6061c7ea9f7bfb6302a380b04978e2ad |
| tree | 0f9500e7d8afc73b83db6e1608ba721837ae8e5a |
| parent | 041ae87b987fbb1a1c8b286e09123965073ccc0a |
| parent | 4ea1aaf7982b9dcb3388058f3113de2856192575 |
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35629
Reviewed-by: Andrew Kelley <andrew@ziglang.org>2 files changed, 6 insertions(+), 1 deletions(-)
lib/std/Io/net.zig+1-1| ... | ... | @@ -576,7 +576,7 @@ pub const Ip6Address = struct { |
| 576 | 576 | const name = text[text_i..]; |
| 577 | 577 | if (name.len == 0) return .incomplete; |
| 578 | 578 | interface_name_text = name; |
| 579 | text_i = @intCast(text.len); | |
| 579 | text_i = std.math.cast(u8, text.len) orelse return .{ .overflow = text.len }; | |
| 580 | 580 | continue :state .end; |
| 581 | 581 | }, |
| 582 | 582 | else => return .{ .invalid_byte = text_i }, |
lib/std/Io/net/test.zig+5| ... | ... | @@ -92,6 +92,11 @@ test "invalid but parseable IPv6 scope ids" { |
| 92 | 92 | try testing.expectError(error.InterfaceNotFound, net.IpAddress.resolveIp6(io, "ff01::fb%123s45678901234", 0)); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | test "oversized IPv6 scope id" { | |
| 96 | const long_scope: [256]u8 = @splat('a'); | |
| 97 | try testing.expectError(error.ParseFailed, net.IpAddress.resolveIp6(testing.io, "ff01::fb%" ++ &long_scope, 0)); | |
| 98 | } | |
| 99 | ||
| 95 | 100 | test "parse and render IPv4 addresses" { |
| 96 | 101 | try testIp4ParseAndRender("0.0.0.0"); |
| 97 | 102 | try testIp4ParseAndRender("255.255.255.255"); |