Commit 3b69a48 1 parent a5ccf46 commit 3b69a48 Copy full SHA for 3b69a48
File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,14 @@ local function rtnl_send(msg)
54
54
return nil , err
55
55
end
56
56
57
+ local function is_valid_mac (mac )
58
+ if type (mac ) ~= ' string' then
59
+ return false
60
+ end
61
+
62
+ return not not mac :match (' ^%x%x:%x%x:%x%x:%x%x:%x%x:%x%x$' )
63
+ end
64
+
57
65
local link = {}
58
66
59
67
--[[
@@ -157,10 +165,12 @@ function link.set(dev, attrs)
157
165
end
158
166
159
167
if attrs .address then
168
+ assert (is_valid_mac (attrs .address ), ' not a valid address' )
160
169
msg :put_attr (rtnl .IFLA_ADDRESS , hex .decode (attrs .address :gsub (' :' , ' ' )))
161
170
end
162
171
163
172
if attrs .broadcast then
173
+ assert (is_valid_mac (attrs .broadcast ), ' not a valid broadcast' )
164
174
msg :put_attr (rtnl .IFLA_BROADCAST , hex .decode (attrs .broadcast :gsub (' :' , ' ' )))
165
175
end
166
176
You can’t perform that action at this time.
0 commit comments