aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuna <git@l4.pm>2020-04-02 18:13:10 -0300
committerAndrew Kelley <andrew@ziglang.org>2020-06-02 14:56:06 -0400
commitb72c862725f6005250cb906e96d41bd1b80fd7ca (patch)
treefbb9394570d900c4335ea1276c8c3a274f647f28 /lib
parentaebf28eba313f6472395bd3fbba3f79dba5326bd (diff)
downloadzig-b72c862725f6005250cb906e96d41bd1b80fd7ca.tar.gz
zig-b72c862725f6005250cb906e96d41bd1b80fd7ca.zip
Use IFNAMESIZE for scope id value
Diffstat (limited to 'lib')
-rw-r--r--lib/std/net.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/std/net.zig b/lib/std/net.zig
index 96442b9933..866a7b0cca 100644
--- a/lib/std/net.zig
+++ b/lib/std/net.zig
@@ -204,7 +204,7 @@ pub const Address = extern union {
var abbrv = false;
var scope_id = false;
- var scope_id_value: [16]u8 = undefined;
+ var scope_id_value: [os.IFNAMESIZE - 1]u8 = undefined;
var scope_id_index: usize = 0;
for (buf) |c, i| {
@@ -215,6 +215,10 @@ pub const Address = extern union {
(c >= 'a' and c <= 'z') or
(c == '-') or (c == '.') or (c == '_') or (c == '~'))
{
+ if (scope_id_index >= scope_id_value.len) {
+ return error.Overflow;
+ }
+
scope_id_value[scope_id_index] = c;
scope_id_index += 1;
} else {