Skip to content

Commit

Permalink
Make readLine more strict.
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Jun 27, 2016
1 parent 1d69f3f commit 5d0dda6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 7 additions & 5 deletions parser.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package redis

import (
"bufio"
"errors"
"fmt"
"net"
Expand All @@ -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")

//------------------------------------------------------------------------------

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion race_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ var _ = Describe("races", func() {
Expect(got).To(Equal(bigVal))
}
})

})

It("should handle big vals in Set", func() {
Expand Down

0 comments on commit 5d0dda6

Please sign in to comment.