Page 1 of 1

[0.11.3] Lua leaks computers account name/data path

Posted: Tue Nov 25, 2014 2:21 pm
by Plorntus
Im not terribly good at Lua so I have no idea if this is an issue with how lua is done or if this is an issue with serpent getting the bytecode for a function in a higher context than the mod is run in however:

This is the least amount of code I could get it to work with

Code: Select all

local test = {};
function test:new () 
	return {};
end
function test:print () 
end
local p,s = pcall(load("return _ENV;", nil, "t", { test:new(), test }));
local path = string.match(serpent.line(s), ".-/(.-)|.*")
game.player.print(path);

When it prints out the result of that it gives a string pointing to the path of the mod:

Image

Now, im not sure how "bad" this is or if something else is going on here. I mean its not a major issue, just something that might want to be looked into. I found this whilst debugging a mod which runs lua scripts in computers in game so would be thankful if you didn't just remove pcall or load and could find a different way of sorting this out (if it needs to be).

Thanks!

Re: [0.11.3] Lua leaks computers account name/data path

Posted: Wed Nov 26, 2014 10:06 pm
by MF-
I guess that depends on who is able to see such information.
If you use that mod in an MP game, will everyone on the network see?

Hiding this information from mods just in case seems sensible to me

Re: [0.11.3] Lua leaks computers account name/data path

Posted: Wed Nov 26, 2014 10:11 pm
by kovarex
I don't know what exactly is happening there, but it is clearly a bug.

Re: [0.11.3] Lua leaks computers account name/data path

Posted: Wed Nov 26, 2014 10:25 pm
by DaveMcW
It's the debug library.

Code: Select all

game.player.print(debug.getinfo(1).source)

Re: [0.11.3] Lua leaks computers account name/data path

Posted: Wed Nov 26, 2014 10:50 pm
by Plorntus
DaveMcW wrote:It's the debug library.

Code: Select all

game.player.print(debug.getinfo(1).source)

Ah, that makes much more sense than the long winded example I had (wasnt sure on the internals so didnt know thats essentially what its doing). Does this mean 'debug' would need to be removed to fix this? As I am currently using debug.sethook to ensure sandboxed scripts inside my mod cant get put in an infinite loop and halt the game.

Re: [0.11.3] Lua leaks computers account name/data path

Posted: Thu Nov 27, 2014 5:58 am
by starxplor
If you are worried about a mod having access to its own location in your storage system, I suggest not using that mod.

General rule is not to download anything(not just mods) that you do not trust enough to know where it is.

Re: [0.11.3] Lua leaks computers account name/data path

Posted: Thu Dec 04, 2014 10:37 am
by cube
This is fixed for 0.11.4. The full file path should not appear anywhere, instead only a logical package name and a path inside that package is used (for example __base__/some_file.lua)