improvement

This commit is contained in:
2025-08-01 17:14:47 -03:00
parent 336303389a
commit 37de2f29e0

View File

@@ -189,15 +189,16 @@ func IsSafe(str string) bool {
} }
func safeRemove(L *lua.LState) int { func safeRemove(L *lua.LState) int {
path := L.CheckString(1) path := L.ToString(1)
if !strings.HasPrefix(path, safeBase) { if !IsSafe(path) {
L.Push(lua.LString("acesso negado")) L.Push(lua.LFalse)
return 1 return 1
} }
err := os.Remove(path) err := os.Remove(path)
if err != nil { if err != nil {
L.Push(lua.LString(err.Error())) L.Push(lua.LFalse)
return 1 return 1
} }
return 0 L.Push(lua.LTrue)
return 1
} }