Sanitizing some client input (fixes #67)

This commit is contained in:
Timo Smit 2017-01-16 19:49:00 +01:00
parent 6e4b5b97a7
commit c0d2aa0e92
13 changed files with 26 additions and 26 deletions

View file

@ -35,7 +35,7 @@ function commandRemoveWarn(clientId, cmdArguments)
cmdClient = tonumber(cmdArguments[1])
end
if cmdClient == -1 then
if cmdClient == -1 or cmdClient > et.trap_Cvar_Get("sv_maxclients") then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^ddewarn: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
return true

View file

@ -31,7 +31,7 @@ function commandListAliases(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases usage: "..commands.getadmin("listaliases")["syntax"].."\";")
return true
elseif tonumber(cmdArguments[1]) == nil then
elseif tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > et.trap_Cvar_Get("sv_maxclients") then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])

View file

@ -57,7 +57,7 @@ function commandListLevels(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels: ^9level history is disabled.\";")
return true
elseif tonumber(cmdArguments[1]) == nil then
elseif tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])

View file

@ -25,7 +25,7 @@ function commandPlayerLock(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock usage: "..commands.getadmin("plock")["syntax"].."\";")
return true
elseif tonumber(cmdArguments[1]) == nil then
elseif tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])

View file

@ -25,7 +25,7 @@ function commandPlayerUnlock(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dpunlock usage: "..commands.getadmin("punlock")["syntax"].."\";")
return true
elseif tonumber(cmdArguments[1]) == nil then
elseif tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])

View file

@ -23,7 +23,7 @@ local admin = require "luascripts.wolfadmin.admin.admin"
function commandSetLevel(clientId, cmdArguments)
if #cmdArguments < 2 then
return false
elseif tonumber(cmdArguments[1]) == nil then
elseif tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])

View file

@ -32,7 +32,7 @@ function commandShowWarns(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowwarns usage: "..commands.getadmin("showwarns")["syntax"].."\";")
return true
elseif tonumber(cmdArguments[1]) == nil then
elseif tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])

View file

@ -23,7 +23,7 @@ function commandShowStats(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats usage: "..commands.getadmin("stats")["syntax"].."\";")
return true
elseif tonumber(cmdArguments[1]) == nil then
elseif tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])

View file

@ -24,7 +24,7 @@ function commandVoiceMute(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute usage: "..commands.getadmin("vmute")["syntax"].."\";")
return true
elseif tonumber(cmdArguments[1]) == nil then
elseif tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])

View file

@ -23,7 +23,7 @@ function commandVoiceUnmute(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvunmute usage: "..commands.getadmin("vunmute")["syntax"].."\";")
return true
elseif tonumber(cmdArguments[1]) == nil then
elseif tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])

View file

@ -25,7 +25,7 @@ function commandAddWarn(clientId, cmdArguments)
return false
elseif #cmdArguments < 2 then
return false
elseif tonumber(cmdArguments[1]) == nil then
elseif tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])

View file

@ -22,7 +22,7 @@ function commandPersonalMessage(clientId, cmdArguments)
if #cmdArguments > 1 then
local cmdClient
if tonumber(cmdArguments[1]) == nil then
if tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])

View file

@ -127,7 +127,7 @@ function commands.log(clientId, command, cmdArguments)
if cmdArguments[1] then
local cmdClient
if tonumber(cmdArguments[1]) == nil then
if tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1])
else
cmdClient = tonumber(cmdArguments[1])