Преглед изворни кода

Fix: Validate MACs in get_dhcp_leases() function

Gogs пре 2 месеци
родитељ
комит
8374102ae0
1 измењених фајлова са 4 додато и 2 уклоњено
  1. 4 2
      package/src/client2server-minimal.lua

+ 4 - 2
package/src/client2server-minimal.lua

@@ -240,7 +240,8 @@ local function get_dhcp_leases()
         f:close()
         if result:match('"leases"') then
             for ip, mac in result:gmatch('"ip":"([%d%.]+)"[^}]*"mac":"([a-fA-F0-9:]+)"') do
-                leases[mac] = {ip=ip, mac=mac}
+                -- Validate MAC before adding
+                if is_valid_mac(mac) then leases[mac] = {ip=ip, mac=mac} end
             end
             return leases
         end
@@ -251,7 +252,8 @@ local function get_dhcp_leases()
     if f then
         for line in f:lines() do
             local e, mac, ip, h, c = line:match("^(%S+) (%S+) (%S+) (%S+) (%S+)")
-            if mac then leases[mac] = {ip=ip, mac=mac, hostname=h} end
+            -- Validate MAC before adding
+            if mac and is_valid_mac(mac) then leases[mac] = {ip=ip, mac=mac, hostname=h} end
         end
         f:close()
     end