Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(es_extended/server/modules/commands.lua): Add Validation Number #1617

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

YOMAN1792
Copy link
Contributor

Description

This prevents the use of values exceeding the IEEE 754 double-precision floating-point limit.
Entering a value higher than this limit would cause ox to stop functioning and produce the following error: SEND_NUI_MESSAGE: invalid JSON passed in frame (rapidjson error code 3).
Additionally, if you attempt to remove money exceeding this limit, ox would no longer be functioning and you would no longer be able to give any more money. This would require manually resetting your money and removing cash-based items from the database to restore normal functionality.


Motivation

This change prevents admins from unintentionally or maliciously causing issues for players.


Implementation Details

Improving server-side protections is crucial, as you can never fully anticipate the intentions of people you don’t know well.
More security is always better than less.


Usage Example

When attempting to give an item, add, or remove money, an error will be displayed if the value exceeds the maximum allowed limit: 1.79769e+308.


PR Checklist

  • My commit messages and PR title follow the Conventional Commits standard.
  • My changes have been tested locally and function as expected.
  • My PR does not introduce any breaking changes.
  • I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

item.count = item.count + count
self.weight = self.weight + (item.weight * count)
count += item.count
item.count = (count <= MAX_AMOUNT and count) or MAX_AMOUNT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ESX.Math.Round here

@@ -403,15 +407,14 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
---@return nil
function self.addInventoryItem(itemName, count)
local item = self.getInventoryItem(itemName)
if not item then return end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best if we dont return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In-Development
Development

Successfully merging this pull request may close these issues.

2 participants