Skip to content

Commit

Permalink
fix index out of range when sid len = 1
Browse files Browse the repository at this point in the history
add unit test for sess_file.go
  • Loading branch information
jianzhiyao committed Jul 13, 2020
1 parent 3db3138 commit 5940ae3
Show file tree
Hide file tree
Showing 2 changed files with 392 additions and 1 deletion.
6 changes: 5 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,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
}
Expand Down
Loading

0 comments on commit 5940ae3

Please sign in to comment.