From 5d3f71b614c6effdcf3360592d5aae514bd96839 Mon Sep 17 00:00:00 2001 From: seud0nym Date: Tue, 21 Feb 2023 17:39:26 +1100 Subject: [PATCH] Nil protection --- .../common/devices/www/docroot/modals/device-modal.lp | 10 ++++++---- .../common/devices/www/lua/devicescard_helper.lua | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build/lua/additional/common/devices/www/docroot/modals/device-modal.lp b/build/lua/additional/common/devices/www/docroot/modals/device-modal.lp index 3a69ff8c..c8174422 100644 --- a/build/lua/additional/common/devices/www/docroot/modals/device-modal.lp +++ b/build/lua/additional/common/devices/www/docroot/modals/device-modal.lp @@ -56,10 +56,12 @@ for _,p in ipairs(proxy.getPN("uci.dhcp.host.",true)) do local json = curl:read("*a") local devices = dkjson.decode(json) curl:close() - ap = gsub(ap,"_"," ") - for _,v in ipairs(devices) do - agentSTA[untaint(v.mac)] = format("%s - %s",ap,v.radio) - remoteSTAs = remoteSTAs + 1 + if devices then + ap = gsub(ap,"_"," ") + for _,v in ipairs(devices) do + agentSTA[untaint(v.mac)] = format("%s - %s",ap,v.radio) + remoteSTAs = remoteSTAs + 1 + end end else ngx.log(ngx.ERR,cmd) diff --git a/build/lua/additional/common/devices/www/lua/devicescard_helper.lua b/build/lua/additional/common/devices/www/lua/devicescard_helper.lua index 60cc3b4f..e9946e29 100644 --- a/build/lua/additional/common/devices/www/lua/devicescard_helper.lua +++ b/build/lua/additional/common/devices/www/lua/devicescard_helper.lua @@ -51,7 +51,7 @@ function M.getDevicesCardHTML(all) local json = curl:read("*a") local devices = dkjson.decode(json) curl:close() - nAPDevices = nAPDevices + #devices + nAPDevices = nAPDevices + (#devices or 0) else ngx.log(ngx.ERR,format("curl -qsklm1 --connect-timeout 1 http://%s:59595",ipv4[1].value)) end