diff options
Diffstat (limited to 'src/loslib.c')
-rw-r--r-- | src/loslib.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/loslib.c b/src/loslib.c index 4715daa..530af6b 100644 --- a/src/loslib.c +++ b/src/loslib.c @@ -47,6 +47,11 @@ static int os_remove (lua_State *L) { Previous_message = oslib_errbuf; return os_pushresult(L, 0, filename); } + else if (contains(filename, "./")) { + snprintf(oslib_errbuf, 1024, "app tried to remove file '%s'; relative paths are never allowed", filename); + Previous_message = oslib_errbuf; + return os_pushresult(L, 0, filename); + } else if (!file_operation_permitted(filename, "w")) { snprintf(oslib_errbuf, 1024, "app tried to remove file '%s'; give it write permissions (ctrl-p) if that is expected", filename); Previous_message = oslib_errbuf; @@ -69,6 +74,11 @@ static int os_rename (lua_State *L) { Previous_message = oslib_errbuf; return os_pushresult(L, 0, fromname); } + else if (contains(fromname, "./")) { + snprintf(oslib_errbuf, 1024, "app tried to rename file '%s'; relative paths are never allowed", fromname); + Previous_message = oslib_errbuf; + return os_pushresult(L, 0, fromname); + } else if (!file_operation_permitted(fromname, "r")) { snprintf(oslib_errbuf, 1024, "app tried to rename file '%s'; give it read permissions (ctrl-p) if that is expected", fromname); Previous_message = oslib_errbuf; @@ -82,6 +92,11 @@ static int os_rename (lua_State *L) { Previous_message = oslib_errbuf; return os_pushresult(L, 0, toname); } + else if (contains(fromname, "./")) { + snprintf(oslib_errbuf, 1024, "app tried to rename to file '%s'; relative paths are never allowed", toname); + Previous_message = oslib_errbuf; + return os_pushresult(L, 0, toname); + } else if (!file_operation_permitted(toname, "w")) { snprintf(oslib_errbuf, 1024, "app tried to rename to file '%s'; give it write permissions (ctrl-p) if that is expected", toname); Previous_message = oslib_errbuf; |