Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sbRoot = "/sandboxed/" --#The path programs shouldn't escape
- local function sandboxCheck(path)
- local fullPath = fs.combine(sbRoot, path)
- local splitPath = split(fullPath, "/")
- local sbRootSP = split(sbRoot, "/")
- local ssPath = ""
- local ssFPath = ""
- for i, v in ipairs(splitPath) do
- ssPath = ssPath .. " " .. v
- if i <= #sbRootSP then
- if not isEmpty(sbRootSP[i]) then
- ssFPath = ssFPath .. " " .. sbRootSP[i]
- end
- end
- end
- for i, v in ipairs(sbRootSP) do
- if not string.match(ssPath, v) then
- print("BYPASS ATTEMPT IN: " .. path)
- return false
- end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement