Team Spartan Cookies & Milk Forums

Full Version: require() execute-only files allows us to modify them
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[Image: snip.png]
You can work around that by doing this:
Code:
local function fatal(msg, level)
    error(msg, level or 0 + 1)
    return "error" + "error"
end
This causes the Lua engine itself to throw an error if the function does not. pcall might still catch this, but the code gets aborted still, so you get what you want. In addition, for legit users everything works as it should.

Note: I don't think there's anything beyond that you can do. What you're describing is an intentional feature of Lua - and it's the basis of all libraries. You could ask person to run every included file within it's own global environment, effectively preventing this, but no library would work anymore. And besides that, someone might want to redefine the error function like this (like me, so that the error message includes the stack trace, very useful for debugging).
[Image: snip.png]
You misread the code, there will be an error because you're trying to add two string variables, the return is simply a guarantee that it doesn't get optimized away.
If you think someone is messing with your code then you can also add them to the chip's blacklist.
[Image: snip.png]