do not allow .. in selector

git-svn-id: file:///srv/svn/repo/tokiko/trunk@7 8f5ca974-a7f8-e144-9f80-d41d5039c194
This commit is contained in:
shokara 2021-12-23 19:15:29 +00:00
parent 4feb13d288
commit 524bdb0dd6

View File

@ -96,6 +96,8 @@ func connHandle(c net.Conn) {
if selector == "" {
printGophermap(c, "./")
} else if strings.Contains(selector, "..") {
writeError(c, "Selector contains ..")
} else if selector[0] == '/' {
info, err := os.Stat(selector[1:])
if err != nil {
@ -112,7 +114,7 @@ func connHandle(c net.Conn) {
printFile(c, selector[1:])
}
} else {
writeError(c, "Selector doesn't start with a / or it contains a ..")
writeError(c, "Selector doesn't start with a /")
}
c.Close()