1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-10 08:30:18 +00:00

fix index out of range when sid len = 1

add unit test for sess_file.go
This commit is contained in:
jianzhiyao
2020-07-13 19:14:53 +08:00
parent 3db31385cf
commit 5940ae33c2
2 changed files with 392 additions and 1 deletions

View File

@ -15,11 +15,11 @@
package session
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
"errors"
"path"
"path/filepath"
"strings"
@ -180,6 +180,10 @@ func (fp *FileProvider) SessionExist(sid string) bool {
filepder.lock.Lock()
defer filepder.lock.Unlock()
if len(sid) < 2 {
return false
}
_, err := os.Stat(path.Join(fp.savePath, string(sid[0]), string(sid[1]), sid))
return err == nil
}