mirror of https://github.com/go-redis/redis.git
Make readLine more strict.
This commit is contained in:
parent
a905127dc8
commit
b5e368500d
12
parser.go
12
parser.go
|
@ -1,6 +1,7 @@
|
||||||
package redis
|
package redis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
@ -19,9 +20,7 @@ const (
|
||||||
|
|
||||||
type multiBulkParser func(cn *pool.Conn, n int64) (interface{}, error)
|
type multiBulkParser func(cn *pool.Conn, n int64) (interface{}, error)
|
||||||
|
|
||||||
var (
|
var errEmptyReply = errors.New("redis: reply is empty")
|
||||||
errReaderTooSmall = errors.New("redis: reader is too small")
|
|
||||||
)
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -227,10 +226,13 @@ func scan(b []byte, val interface{}) error {
|
||||||
func readLine(cn *pool.Conn) ([]byte, error) {
|
func readLine(cn *pool.Conn) ([]byte, error) {
|
||||||
line, isPrefix, err := cn.Rd.ReadLine()
|
line, isPrefix, err := cn.Rd.ReadLine()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return line, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if isPrefix {
|
if isPrefix {
|
||||||
return line, errReaderTooSmall
|
return nil, bufio.ErrBufferFull
|
||||||
|
}
|
||||||
|
if len(line) == 0 {
|
||||||
|
return nil, errEmptyReply
|
||||||
}
|
}
|
||||||
if isNilReply(line) {
|
if isNilReply(line) {
|
||||||
return nil, Nil
|
return nil, Nil
|
||||||
|
|
|
@ -120,7 +120,6 @@ var _ = Describe("races", func() {
|
||||||
Expect(got).To(Equal(bigVal))
|
Expect(got).To(Equal(bigVal))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should handle big vals in Set", func() {
|
It("should handle big vals in Set", func() {
|
||||||
|
|
Loading…
Reference in New Issue