-
Notifications
You must be signed in to change notification settings - Fork 333
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
Validate I/O in case addons pass incorrect values #2720
Conversation
lua/wire/server/wirelib.lua
Outdated
local ty = WireLib.DT[output.Type] | ||
if ty and not ty.Validator(value) then | ||
-- Not copying here is fine since data types are immutable outside E2. | ||
value = ty.Zero |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should return a copy of 'Zero'. Maybe change 'ty.Zero' into a function that returns a new zero so this line becomes value = ty.Zero()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how ports handle mutable types, so maybe I'm wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wire just doesn't mutate any data types, and E2 table.Copy
s the types before using them and outputting them.
But since this is a PR to fix addon creators potentially messing stuff up, might as well do this too in case they mutate the default value.
Um, one other issue is this is going to fuck performance in x64 gmod. Facepunch/garrysmod-issues#4100 |
I mean, this is serverside, I doubt many servers are hosted on 64 bit |
Yeah |
This applies to wiremod as a whole, now inputs and outputs will be validated to ensure correctness on TriggerInput/TriggerOutput (E2 wirelinks use this as well).
In this case the value will be replaced with the default value for the type.