Skip to content

Commit

Permalink
Merge pull request beego#4068 from jianzhiyao/fix_3898
Browse files Browse the repository at this point in the history
fix `index out of range` when sid len = 1
  • Loading branch information
flycash authored Jul 14, 2020
2 parents 3db3138 + 678b903 commit 1c07144
Show file tree
Hide file tree
Showing 2 changed files with 393 additions and 1 deletion.
7 changes: 6 additions & 1 deletion session/sess_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
package session

import (
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
"errors"
"path"
"path/filepath"
"strings"
Expand Down Expand Up @@ -180,6 +180,11 @@ func (fp *FileProvider) SessionExist(sid string) bool {
filepder.lock.Lock()
defer filepder.lock.Unlock()

if len(sid) < 2 {
SLogger.Println("min length of session id is 2", sid)
return false
}

_, err := os.Stat(path.Join(fp.savePath, string(sid[0]), string(sid[1]), sid))
return err == nil
}
Expand Down
Loading

0 comments on commit 1c07144

Please sign in to comment.