mirror of
https://github.com/astaxie/beego.git
synced 2025-07-10 02:30:18 +00:00
session: #620 make the session never read empty
This commit is contained in:
@ -20,6 +20,8 @@ import (
|
||||
"io"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -60,8 +62,8 @@ func DecodeGob(encoded []byte) (map[interface{}]interface{}, error) {
|
||||
// generateRandomKey creates a random key with the given strength.
|
||||
func generateRandomKey(strength int) []byte {
|
||||
k := make([]byte, strength)
|
||||
if _, err := io.ReadFull(rand.Reader, k); err != nil {
|
||||
return nil
|
||||
if n, err := io.ReadFull(rand.Reader, k); n != strength || err != nil {
|
||||
return utils.RandomCreateBytes(strength)
|
||||
}
|
||||
return k
|
||||
}
|
||||
|
Reference in New Issue
Block a user