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