mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-01 02:38:53 +00:00
Fixed exploit with negative values and decimals
All float values are now rounded to a number. There's also an check for if the input is less than or equal to 0
This commit is contained in:
+24
-4
@@ -77,12 +77,28 @@ Citizen.CreateThread(function()
|
||||
RegisterNUICallback('menu_submit', function(data, cb)
|
||||
|
||||
local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name)
|
||||
local post = true
|
||||
|
||||
if menu.submit ~= nil then
|
||||
if(type(data.value) == "number") then
|
||||
data.value = math.floor(tonumber(data.value))
|
||||
|
||||
-- Is the submitted data a number?
|
||||
if tonumber(data.value) ~= nil then
|
||||
|
||||
-- Round float values
|
||||
data.value = round(tonumber(data.value))
|
||||
|
||||
-- Check for negative value
|
||||
if tonumber(data.value) <= 0 then
|
||||
post = false
|
||||
end
|
||||
end
|
||||
|
||||
-- Don't post if the value is negative or if it's 0
|
||||
if post then
|
||||
menu.submit(data, menu)
|
||||
else
|
||||
ESX.ShowNotification('That input is invalid!')
|
||||
end
|
||||
menu.submit(data, menu)
|
||||
end
|
||||
|
||||
cb('OK')
|
||||
@@ -141,4 +157,8 @@ Citizen.CreateThread(function()
|
||||
end
|
||||
end)
|
||||
|
||||
end)
|
||||
end)
|
||||
|
||||
function round(x)
|
||||
return x>=0 and math.floor(x+0.5) or math.ceil(x-0.5)
|
||||
end
|
||||
Reference in New Issue
Block a user