This commit is contained in:
Pinya
2018-07-18 18:54:19 +03:00
parent 7bc657722b
commit c48ab12e82
2 changed files with 55 additions and 43 deletions
+1 -1
View File
@@ -340,7 +340,7 @@ function table.maxn(t)
end end
local maxn = 0 local maxn = 0
local i = next(t, nil) local i = next(t)
while i do while i do
if type(i) == "number" and i > maxn then if type(i) == "number" and i > maxn then
+53 -41
View File
@@ -120,54 +120,66 @@ function hooksecurefunc(a1, a2, a3)
end end
end end
local secureFuncs = { local secureFunctions = {
CameraOrSelectOrMoveStop = true, ["CameraOrSelectOrMoveStop"] = true,
MoveBackwardStop = true, ["MoveBackwardStop"] = true,
MoveForwardStop = true, ["MoveForwardStop"] = true,
PitchDownStop = true, ["PitchDownStop"] = true,
PitchUpStop = true, ["PitchUpStop"] = true,
StrafeLeftStart = true, ["StrafeLeftStart"] = true,
StrafeRightStart = true, ["StrafeRightStart"] = true,
ToggleMouseMove = true, ["ToggleMouseMove"] = true,
TurnLeftStart = true, ["TurnLeftStart"] = true,
TurnOrActionStop = true, ["TurnOrActionStop"] = true,
TurnRightStart = true, ["TurnRightStart"] = true,
CameraOrSelectOrMoveStart = true, ["CameraOrSelectOrMoveStart"] = true,
Jump = true, ["Jump"] = true,
MoveBackwardStart = true, ["MoveBackwardStart"] = true,
MoveForwardStart = true, ["MoveForwardStart"] = true,
PitchDownStart = true, ["PitchDownStart"] = true,
PitchUpStart = true, ["PitchUpStart"] = true,
StrafeLeftStop = true, ["StrafeLeftStop"] = true,
StrafeRightStop = true, ["StrafeRightStop"] = true,
ToggleRun = true, ["ToggleRun"] = true,
TurnLeftStop = true, ["TurnLeftStop"] = true,
TurnOrActionStart = true, ["TurnOrActionStart"] = true,
TurnRightStop = true ["TurnRightStop"] = true
} }
--[[ issecurevariable([table], variable) local secureScripts = {}
Returns 1, nil for undefined variables. This is because an undefined variable is secure since you have not tainted it. function issecurevariable(a1, a2)
Returns 1, nil for all untainted variables (i.e. Blizzard variables). -- local isMethod = type(a1) == "table" and type(a2) == "string" and type(a1[a2]) == "function"
Returns nil for any global variable that is hooked insecurely (tainted), even unprotected ones like UnitName(). -- if not (isMethod or (type(a1) == "string" and type(_G[a1]) == "function") then
Returns nil for all user defined global variables.
If a table is passed first, it checks table.variable (e.g. issecurevariable(PlayerFrame, "Show") checks PlayerFrame["Show"] or PlayerFrame.Show (they are the same thing)).
]]
function issecurevariable(t, var)
-- if type(var) ~= "table" or type(var) ~= "string" then
-- error("Usage: issecurevariable([table,] \"variable\")", 2) -- error("Usage: issecurevariable([table,] \"variable\")", 2)
-- end -- end
--
-- local isSecure
-- if isMethod then
-- isSecure = secureScripts[a2] and 1
-- else
-- isSecure = secureFunctions[a1] and 1
-- end
--
-- return isSecure
local isSecure = secureFuncs[t] and 1 or nil if type(a1) == "table" then return end
if not isSecure then
return if type(a1) ~= "string" then
error("Usage: issecurevariable([table,] \"variable\")", 2)
end end
local taint return secureFunctions[a1] and 1
for x in gmatch(debugstack(), "\\AddOns\\(.-)\\") do end
taint = x
end
return isSecure, taint function issecure()
return
end
function securecall(f, ...)
if arg.n > 0 then
_G[f](unpack(arg))
else
_G[f]()
end
end end
function tContains(table, item) function tContains(table, item)