improvement
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user