| author | |
| committer | |
| log | e7a418e13155cf2568c6b64d9d51ad61db8dd37b |
| tree | a7ac1a51c0acdc37c998e00ae973297808565ac7 |
| parent | 041ae87b987fbb1a1c8b286e09123965073ccc0a |
2 files changed, 7 insertions(+), 2 deletions(-)
lib/std/Io/net.zig+2-2| ... | @@ -512,7 +512,7 @@ pub const Ip6Address = struct { | ... | @@ -512,7 +512,7 @@ pub const Ip6Address = struct { |
| 512 | // Has to be u16 elements to handle 3-digit hex numbers from compression. | 512 | // Has to be u16 elements to handle 3-digit hex numbers from compression. |
| 513 | var parts: [8]u16 = @splat(0); | 513 | var parts: [8]u16 = @splat(0); |
| 514 | var parts_i: u8 = 0; | 514 | var parts_i: u8 = 0; |
| 515 | var text_i: u8 = 0; | 515 | var text_i: usize = 0; |
| 516 | var digit_i: u8 = 0; | 516 | var digit_i: u8 = 0; |
| 517 | var compress_start: ?u8 = null; | 517 | var compress_start: ?u8 = null; |
| 518 | var interface_name_text: ?[]const u8 = null; | 518 | var interface_name_text: ?[]const u8 = null; |
| ... | @@ -576,7 +576,7 @@ pub const Ip6Address = struct { | ... | @@ -576,7 +576,7 @@ pub const Ip6Address = struct { |
| 576 | const name = text[text_i..]; | 576 | const name = text[text_i..]; |
| 577 | if (name.len == 0) return .incomplete; | 577 | if (name.len == 0) return .incomplete; |
| 578 | interface_name_text = name; | 578 | interface_name_text = name; |
| 579 | text_i = @intCast(text.len); | 579 | text_i = text.len; |
| 580 | continue :state .end; | 580 | continue :state .end; |
| 581 | }, | 581 | }, |
| 582 | else => return .{ .invalid_byte = text_i }, | 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,6 +92,11 @@ test "invalid but parseable IPv6 scope ids" { |
| 92 | try testing.expectError(error.InterfaceNotFound, net.IpAddress.resolveIp6(io, "ff01::fb%123s45678901234", 0)); | 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.NameTooLong, net.IpAddress.resolveIp6(testing.io, "ff01::fb%" ++ &long_scope, 0)); | ||
| 98 | } | ||
| 99 | |||
| 95 | test "parse and render IPv4 addresses" { | 100 | test "parse and render IPv4 addresses" { |
| 96 | try testIp4ParseAndRender("0.0.0.0"); | 101 | try testIp4ParseAndRender("0.0.0.0"); |
| 97 | try testIp4ParseAndRender("255.255.255.255"); | 102 | try testIp4ParseAndRender("255.255.255.255"); |