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
Enable safe Lua os.* functions #316
Conversation
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.
Thanks. Please move to InitSecurity and set as a disabled function
You should enable http://lua-users.org/wiki/OsLibraryTutorial |
@CrosRoad95 os.tmpname returns a string with the full directory. It might be a security concern. |
os.clock returns seconds, while getTickCount() returns ms |
@Pirulax it returns a float of 0.001 precision in seconds format, which is the same as milliseconds. |
I dont know. |
@Pirulax it does return seconds, but in 0.001 precision. Read the example from Lua documentation: http://lua-users.org/wiki/OsLibraryTutorial |
I'm just going to give my two cents here to @Dezash: wouldn't it be better to push the I think (but I'm not sure, I'm not an active C++ developer who works with Lua) you can use |
@AlexTMjugador agreed. I did mention this in my review but I don't think he noticed 🙂 |
Good idea, I missed qaisjp's note somehow. |
We might want to disable |
Loads Lua Os library and disables the following functions:
The following functions are enabled:
These functions are much faster than MTA's substitute functions.
Here's how os.clock compares with getTickCount:
Result:
INFO: getTickCount 3926
INFO: os.clock 418
Almost 10 times faster than getTickCount. Considering that functions such as getTickCount or getRealTime are often used onClientRender, this may allow scripters to slightly increase script performance.
This would also help accommodate people who have knowledge of Lua, but are new to MTA.