From ff67ac3bb0bce6208bc7b795006a4406713d651d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=87=E5=BC=BA?= Date: Thu, 11 Jul 2024 17:37:30 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E8=A7=A3=E6=9E=90RDB=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- redis/parser/parser.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/redis/parser/parser.go b/redis/parser/parser.go index 61d4c03d..64110024 100644 --- a/redis/parser/parser.go +++ b/redis/parser/parser.go @@ -4,13 +4,14 @@ import ( "bufio" "bytes" "errors" - "github.com/hdt3213/godis/interface/redis" - "github.com/hdt3213/godis/lib/logger" - "github.com/hdt3213/godis/redis/protocol" "io" "runtime/debug" "strconv" "strings" + + "github.com/hdt3213/godis/interface/redis" + "github.com/hdt3213/godis/lib/logger" + "github.com/hdt3213/godis/redis/protocol" ) // Payload stores redis.Reply or error @@ -155,6 +156,9 @@ func parseBulkString(header []byte, reader *bufio.Reader, ch chan<- *Payload) er // there is no CRLF between RDB and following AOF, therefore it needs to be treated differently func parseRDBBulkString(reader *bufio.Reader, ch chan<- *Payload) error { header, err := reader.ReadBytes('\n') + if err != nil { + return errors.New("failed to read bytes") + } header = bytes.TrimSuffix(header, []byte{'\r', '\n'}) if len(header) == 0 { return errors.New("empty header")