소스 검색

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