| author | |
| committer | |
| log | 4ea1aaf7982b9dcb3388058f3113de2856192575 |
| tree | 0f9500e7d8afc73b83db6e1608ba721837ae8e5a |
| parent | e7a418e13155cf2568c6b64d9d51ad61db8dd37b |
Previous commit fixed the crash but used this error code:
```
/// The interface name is longer than the host operating system supports.
NameTooLong,
```
More appropriate error code based on the documentation is:
```
/// If this is returned, more detailed diagnostics can be obtained by
/// calling the `Parsed.init` function.
ParseFailed,
```2 files changed, 3 insertions(+), 3 deletions(-)
lib/std/Io/net.zig+2-2| ... | ... | @@ -512,7 +512,7 @@ pub const Ip6Address = struct { |
| 512 | 512 | // Has to be u16 elements to handle 3-digit hex numbers from compression. |
| 513 | 513 | var parts: [8]u16 = @splat(0); |
| 514 | 514 | var parts_i: u8 = 0; |
| 515 | var text_i: usize = 0; | |
| 515 | var text_i: u8 = 0; | |
| 516 | 516 | var digit_i: u8 = 0; |
| 517 | 517 | var compress_start: ?u8 = null; |
| 518 | 518 | var interface_name_text: ?[]const u8 = null; |
| ... | ... | @@ -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 = 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+1-1| ... | ... | @@ -94,7 +94,7 @@ test "invalid but parseable IPv6 scope ids" { |
| 94 | 94 | |
| 95 | 95 | test "oversized IPv6 scope id" { |
| 96 | 96 | const long_scope: [256]u8 = @splat('a'); |
| 97 | try testing.expectError(error.NameTooLong, net.IpAddress.resolveIp6(testing.io, "ff01::fb%" ++ &long_scope, 0)); | |
| 97 | try testing.expectError(error.ParseFailed, net.IpAddress.resolveIp6(testing.io, "ff01::fb%" ++ &long_scope, 0)); | |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | test "parse and render IPv4 addresses" { |